I am trying to implement Java Lambda concept for selenium webdriver waits. I need to convert custom webdriver wait something like this
(new WebDriverWait(driver(), 5))
.until(new ExpectedCondition<WebElement>() {
public WebElement apply(WebDriver d) {
return d.findElement(By.linkText(""));
}
});
to
(new WebDriverWait(driver(), 5)).until((driver) -> driver.findElement(By.linkText("")));
But it does not matches the functional interface of 'until' refers to and throws error.
So i tried passing the Lambda as it supports.
Attempt1
Predicate<WebDriver> isVisible = (dr) -> dr.findElement(
By.linkText("")).isDisplayed();
webDriverWait.until(isVisible);
It kind of works but is not what i require because it returns only void.
Need your help or advice on this.