在阅读了一篇关于 JDK1.8 和 Lambda 表达式的文章后,我意识到我最近几年一直在使用的 ExpectedCondition 块可能适合表示为 Lambda 表达式。
鉴于此等待对象:
Wait<WebDriver> wait = new FluentWait<WebDriver>( driver )
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring( NoSuchElementException.class );
谁能告诉我如何将 Selenium 的 ExpectedCondition 表达式转换为 Lambda 表达式?
WebElement foo = wait.until( new ExpectedCondition<Boolean>() {
public WebElement apply( WebDriver webDriver ) {
return webDriver.findElement( By.id("foo") );
}
} );