過ぎてコピーし、単純なテキストを過ぎて所望の出力が得られない以下のあなたが成功したテキスト値を選択することができ、かつ問題がある場合は私のコードセレンアクションクラスは、私がコピーしようとしているテキスト
public class practiceExample2 {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "G:\\TopsAssignment\\SampleJavaExample\\lib\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.facebook.com/");
WebElement elm1 = driver.findElement(By.id("email"));
WebElement elm2 = driver.findElement(By.id("pass"));
Actions cpypast = new Actions(driver);
Action write = cpypast.sendKeys(elm1, "Pratik").build();
Action select = cpypast.doubleClick(elm1).build();
Action copy = cpypast.sendKeys(elm1, Keys.CONTROL).sendKeys(elm1, "C").build();
Action past = cpypast.sendKeys(elm2,Keys.CONTROL).sendKeys(elm2,"V").build();
write.perform();
select.perform();
copy.perform();
past.perform();
String str = elm2.getText();
System.out.println(str);
driver.close();
}
}
は、なぜあなたは 'Actions'クラスを使用しようとしている、それがうまく機能Robotクラスで試してみましたか? – DebanjanB
返信いただきありがとうございます。 Robotクラスとうまく動作します – pratik22