Java 硒自动测试中的FluentWait
我正在使用下面的代码,这是我从StackOverflow答案中得到的:Java 硒自动测试中的FluentWait,java,selenium,Java,Selenium,我正在使用下面的代码,这是我从StackOverflow答案中得到的: Wait Wait=new FluentWait(驱动程序) .带超时(60,时间单位。秒) .轮询间隔(5,时间单位。秒) .忽略(NoSuchElementException.class); wait.until(新函数(){ @凌驾 公共布尔应用(WebDriver驱动程序){ 返回driver.findElement(By.cssSelector(“MyCSS选择器”)).getText()包含(“名称”); } }
Wait Wait=new FluentWait(驱动程序)
.带超时(60,时间单位。秒)
.轮询间隔(5,时间单位。秒)
.忽略(NoSuchElementException.class);
wait.until(新函数(){
@凌驾
公共布尔应用(WebDriver驱动程序){
返回driver.findElement(By.cssSelector(“MyCSS选择器”)).getText()包含(“名称”);
}
});
Eclipse在“直到”上显示错误。当我将鼠标悬停在上面时,它会说:
方法
until(Function一切似乎都很好,只是您可能使用了错误的函数导入
您可能希望使用以下选项:-
Wait<WebDriver> wait = new FluentWait<>(driver)
.withTimeout(60, TimeUnit.SECONDS)
.pollingEvery(5, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);
wait.until(new com.google.common.base.Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
return null;
}
});
Wait Wait=new FluentWait(驱动程序)
.带超时(60,时间单位。秒)
.轮询间隔(5,时间单位。秒)
.忽略(NoSuchElementException.class);
wait.until(new com.google.common.base.Function(){
@凌驾
公共布尔应用(WebDriver驱动程序){
返回null;
}
});