sendkeys对输入字段不起作用

时间:2017-05-05 01:08:19

标签: java selenium

我遇到了一个奇怪的问题。 sendkeys不能在输入字段上工作,虽然我可以点击它。

我也尝试过setAttribute,即使这样也行不通。

输入字段持续监控用户输入,并在用户输入x个字符时触发javascript。这会导致问题吗?

我试过这些:

driver.findElement(By.xpath("//input[@id='id']")).sendKeys(c‌odeStr); 
((JavascriptExecutor) driver).executeScript("document.getElementById('id').value='‌ 
123456'"); 
((JavascriptExecutor) 
driver).executeScript("document.getElementById('id').
setAttr‌ibute('value', '123456')");

这是我收到的错误: org.openqa.selenium.NoSuchElementException:无法找到element:// input [@ id ='id']

但点击工作正常:

driver.findElement(By.xpath("//input[@id='id']")).click();

0 个答案:

没有答案
相关问题