fluentwait<webdriver> 类型中的 withtimeout(duration) 方法不适用于参数 (int, timeunit)
the method withtimeout(duration) in the type fluentwait<webdriver> is not applicable for the arguments (int, timeunit)
使用此代码时出现错误,错误为
"The method withTimeout(Duration) in the type FluentWait is not
applicable for the arguments (int, TimeUnit)"
Wait wait = new FluentWait(driver)
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring(NoSuchElementException.class);
现在这是正确的用法..
Wait wait = new FluentWait(driver).withTimeout(Duration.ofSeconds(30)).pollingEvery(Duration.ofSeconds(30))
.ignoring(NoSuchElementException.class);
我搜索了一下,下面的代码对我有用
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(10, TimeUnit.SECONDS)
.pollingEvery(2, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);
在一个条件下工作后,变量名应该是任何东西而不是 "wait",即 "wait1" 可以工作
#CompleteWaitCode
@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;
}
});
使用此代码时出现错误,错误为
"The method withTimeout(Duration) in the type FluentWait is not applicable for the arguments (int, TimeUnit)"
Wait wait = new FluentWait(driver)
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring(NoSuchElementException.class);
现在这是正确的用法..
Wait wait = new FluentWait(driver).withTimeout(Duration.ofSeconds(30)).pollingEvery(Duration.ofSeconds(30))
.ignoring(NoSuchElementException.class);
我搜索了一下,下面的代码对我有用
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(10, TimeUnit.SECONDS)
.pollingEvery(2, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);
在一个条件下工作后,变量名应该是任何东西而不是 "wait",即 "wait1" 可以工作
#CompleteWaitCode
@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;
}
});