After reading an article about JDK1.8 and Lambda expressions, I realized that the ExpectedCondition block that I have been using for the last few years is probably suitable to be expressed as a Lambda expression.
Given this wait object:
Wait<WebDriver> wait = new FluentWait<WebDriver>( driver )
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring( NoSuchElementException.class );
Can anyone tell me how I can convert this ExpectedCondition expression, for Selenium, into a Lambda expression?
WebElement foo = wait.until( new ExpectedCondition<Boolean>() {
public WebElement apply( WebDriver webDriver ) {
return webDriver.findElement( By.id("foo") );
}
} );
wait.until(webDriver -> webDriver.findElement(By.id("foo")))