如何解决ElementNotInteractableException:Element这里有代码的图像和错误的图像。有人能帮我解决这个问题吗?
3 回答

翻翻过去那场雪
TA贡献2065条经验 获得超14个赞
ElementNotInteractableException
原因及解决办法:
其他临时叠加 WebElement
翻过 WebElement
引起我们的兴趣 :在这种情况下,直接的解决办法是诱导 ExplicitWait
E. WebDriverWait
结合在一起 ExpectedCondition
如 invisibilityOfElementLocated
作为折页: WebDriverWait wait2 = new WebDriverWait(driver, 10);wait2.until(ExpectedConditions.invisibilityOfElementLocated (By.xpath("xpath_of_element_to_be_invisible")));driver.findElement(By.xpath("xpath_element_to_be_clicked")).click();
一个更好的解决方案是获得更多的粒度,而不是使用 ExpectedCondition
如 invisibilityOfElementLocated
我们可以用 ExpectedCondition
如 elementToBeClickable
详情如下: WebDriverWait wait1 = new WebDriverWait(driver, 10);WebElement element1 = wait1.until(ExpectedConditions.elementToBeClickable (By.xpath("xpath_of_element_to_be_clicked")));element1.click();
其他永久覆盖层 WebElement
翻过 WebElement
引起我们的兴趣 :如果覆盖是永久性的,那么我们必须将 WebDriver
实例作为 JavascriptExecutor
并按以下方式执行单击操作: WebElement ele = driver.findElement(By.xpath("element_xpath"));JavascriptExecutor executor = (JavascriptExecutor)driver; executor.executeScript("arguments[0].click();", ele);
添加回答
举报
0/150
提交
取消