I am trying to use FluentWait in my Selenium Java automation.
When I used the until method, I get the following error the method until(Function in the type Wait is not applicable for the argument(new Function(){}
public WebElement fluentWaitForElement() {
Wait<WebDriver> fluentWait = new FluentWait<WebDriver>(driver)
.withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(5, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);
WebElement waitingElement = fluentWait.until(new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id("ButtonID"));
}
}
);
}
I also tried the solution in another post. But, I still get the same error
fluentWaitwait.until(new Function<WebDriver, Boolean>() {
@Override public Boolean apply(WebDriver driver) {
return driver.findElement(By.ID("ButtonID"));
}
}
);
Does anyone know how to solve this problem? Thanks