3 回答
TA贡献2016条经验 获得超9个赞
这是现在正确的用法..
Wait wait = new FluentWait(driver).withTimeout(Duration.ofSeconds(30)).pollingEvery(Duration.ofSeconds(30)) .ignoring(NoSuchElementException.class);
TA贡献1946条经验 获得超4个赞
我搜索了以下代码对我有用
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(10, TimeUnit.SECONDS) .pollingEvery(2, TimeUnit.SECONDS) .ignoring(NoSuchElementException.class);
TA贡献1853条经验 获得超9个赞
在满足一个条件后,变量名称应该是任何东西而不是“wait”,即“wait1”可以工作
#完整等待代码
@SuppressWarnings("unchecked")
Wait **wait1** = new FluentWait(driver).withTimeout(Duration.ofSeconds(30)).pollingEvery(Duration.ofSeconds(30)).ignoring(NoSuchElementException.class);
@SuppressWarnings("unchecked")
WebElement element = (WebElement) wait1.until(new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver arg0) {
WebElement linkelement = driver.findElement(By.cssSelector("button[class='btn btn-primary']"));
if (linkelement.isEnabled()) {
System.out.println("Element is Found");
}
return linkelement;
}
});
添加回答
举报