Selenium and PhantomJS - can not sendKeys()

922 Views Asked by At

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?

1

There are 1 best solutions below

0
On

First click that element:

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

then pass data by using sendKeys:

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