Selenium和PhantomJS - 无法发送凯斯()

时间:2016-08-28 10:57:34

标签: java selenium selenium-webdriver phantomjs screenshotexception

当我尝试发送密钥时,我发现错误

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"...

代码:

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)

是什么原因?

1 个答案:

答案 0 :(得分:0)

首先单击该元素:

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

然后使用sendKeys传递数据:

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