I'm looking for a way to write this block using lambda:
public void waitUntilElemIsDisabled(WebElement element) {
try {
wait.until(new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
return !element.isEnabled();
}
});
} catch (Exception e) {
e.printStackTrace();
logger.error(e.toString());
}
}
I was trying out wait.until(e -> element.isEnabled());
but I'm getting a syntax error:
The method until(Predicate<WebDriver>) is ambiguous for the type FluentWait<WebDriver>
If it helps, here's how I initialized wait
:
wait = new FluentWait<>(webDriver).withTimeout(impTimeout, s).pollingEvery(pollingMsInt, ms)
.ignoring(NoSuchElementException.class);
I'm fairly new at using lambda, currently following this guide but I can't find a pattern that matches the one i'm using.
Thanks in advance.