如何解决ElementNotInteractableException:Element

如何解决ElementNotInteractableException:Element

这里有代码的图像和错误的图像。有人能帮我解决这个问题吗?



HUX布斯
浏览 8648回答 3
3回答

翻翻过去那场雪

ElementNotInteractableException元素NotInteractableException是W3C异常,该异常被抛出以指示尽管在HTML DOM它并不是处于一个可以相互作用的状态。原因及解决办法:原因ElementNotInteractableException可能发生的事情很多。其他临时叠加WebElement翻过WebElement引起我们的兴趣 :在这种情况下,直接的解决办法是诱导ExplicitWaitE.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);

森栏

Javascript的解决方案如下所示。你必须修改时间以适应你的需要。driver.manage().setTimeouts({ implicit: 30000 });希望这对某人有帮助。见博士供参考
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java