Seleniumの編集ボックスの値を取得するにはどうすればよいですか?
Seleniumの編集ボックスの値は、次の方法で取得できます-
-
getText()メソッドを使用する。
-
クラスJavascriptExecutorを使用します。
getText()。
メソッドを使用したコード実装例
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class GetValueScripting {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String url = "https://www.tutorialspoint.com/index.htm";
driver.get(url);
driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);
String text = driver.findElement(By.className("gsc-input")).getText();
System.out.println("Extracted text is " + text);
driver.close();
}
} クラスJavascriptExecutorを使用したコード実装。
例
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.JavascriptExecutor;
public class ExtractValueScripting {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String url = "https://www.tutorialspoint.com/index.htm";
driver.get(url);
driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);
// create Javascript object
JavascriptExecutor js = (JavascriptExecutor)driver;
// Issue command to extract the text
String text = js.executeScript("return document.getElementById(' gsc-i-id1').value").toString();
System.out.println("Extracted text is" + text);
driver.close();
}
} -
Tkinterでエントリウィジェットの値を取得するにはどうすればよいですか?
エントリウィジェットを作成し、その値を取得したいとします。この場合、 .get()を使用できます 方法。入力オブジェクトを変数にマップします。変数は、入力された値を印刷または表示するためにさらに使用できます。 例 この例では、ラベルウィジェットを介して入力テキストを表示するアプリケーションを作成します。 #Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame or window win= Tk() #Set the geometry o
-
Macで写真を写真に取り込む方法
すべての写真とビデオが完成する場所として、iPhoneまたはiPadの写真アプリに精通しているかもしれませんが、Macで同じアプリを使用して写真を表示および編集できることをご存知ですか? この記事は、Macでの写真の使用に関する一連の記事の一部です。他の場所では、Macアプリを使用して写真やビデオを表示、編集、共有する方法について説明します。また、写真を整理するための最適な方法や、写真にフィルターを追加したり、写真を完璧に見せるために他の調整を行ったりする方法についても説明します。 ただし、そのいずれかを実行する前に、画像をMacに取り込む必要があります。この記事では、iCloud Pho