需要:使用 Selenium 更新 url 上的字段并单击按钮(下面是网页屏幕截图和 HTML 详细信息)
问题:返回如下所示的错误
错误:
Exception in thread "main" org.openqa.selenium.ElementNotInteractableException:
element not interactable
(Session info: chrome=78.0.3904.70)
研究:我引用了以下内容,但无法修复它 - org.openqa.selenium.ElementNotInteractableException: Element is not reachable by keyboard: while sending text to FirstName field in Facebook Selenium WebDriver throws Exception in thread "main" org.openqa.selenium.ElementNotInteractableException
代码:根据其他链接中的建议添加了等待和 sleep ,但仍然不起作用。
WebDriver driver = new ChromeDriver();
driver.get(url);
WebElement email = driver.findElement(By.xpath("//label[contains(text(),'User ID')]"));
WebElement password = driver.findElement(By.xpath("//label[contains(text(),'Password')]"));
new WebDriverWait(driver,20);
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
email.sendKeys("myemail@gmail.com");
HTML 和网页 View : How to resolve ElementNotInteractableException: Element is not visible in Selenium webdriver?
希望所面临的问题很清楚,等待指导。
最佳答案
请尝试以下任何 xpath
//label[contains(text(),'User ID')]/following-sibling::input
//input[@placeholder='User ID']
您的 xpath 正在定位标签。您需要找到<input>
关于java - Selenium - 错误 : element not interactable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58619070/