需要等待
ignoring时,您需要异常调用以忽略
WebDriver。
FluentWait<WebDriver> fluentWait = new FluentWait<>(driver) .withTimeout(30, TimeUnit.SECONDS) .pollingEvery(200, TimeUnit.MILLISECONDS) .ignoring(NoSuchElementException.class);
有关更多信息,请参见FluentWait文档。但是请注意,此条件已经在ExpectedConditions中实现,因此您应该使用
WebElement element = (new WebDriverWait(driver, 10)) .until(ExpectedConditions.elementToBeClickable(By.id("someid")));*更新为更新版本的Selenium:
withTimeout(long, TimeUnit) has become withTimeout(Duration)pollingEvery(long, TimeUnit) has become pollingEvery(Duration)
因此,代码将如下所示:
FluentWait<WebDriver> fluentWait = new FluentWait<>(driver) .withTimeout(Duration.ofSeconds(30) .pollingEvery(Duration.ofMillis(200) .ignoring(NoSuchElementException.class);
等待的基本教程可以在这里找到。



