简体   繁体   中英

Selenium and PhantomJS - can not sendKeys()

When I try to send keys than I get an error

Exception in thread "main" org.openqa.selenium.InvalidElementStateException: {"errorMessage":"Element is not currently interactable and may not be manipulated"...
    at main.Main_1.main(Main_1.java:39)

Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken...

Caused by: org.openqa.selenium.InvalidElementStateException: {"errorMessage":"Element is not currently interactable and may not be manipulated"...

a code:

driver.get("site url");
wait.until( ExpectedConditions.presenceOfElementLocated(By.name("query")) );
System.out.println(driver.getTitle()); //this line works
driver.findElement(By.name("query")).sendKeys("test"); //error here (Main_1.java:39)

What is the reason?

First click that element:

driver.findElement(By.name("query")).click();

then pass data by using sendKeys :

driver.findElement(By.name("query")).sendKeys("test");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM