Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(Duration.ofSeconds(30))
.pollingEvery(Duration.ofMillis(500))
.ignoring(NoSuchElementException.class);
WebElement foo = wait.until(new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
return driver.findElement(By.name("q"));
}
});
Tried to work on Fluent wait implementation with Selenium 3.141.59 but getting the specified compile time error. I am mainly concerned with "new Function method"
I don't believe this is a duplicate. Question may sound the same but none of the solutions worked for me.
Error Shown:
The type Function is not generic; it cannot be parameterized with arguments <WebDriver, WebElement>
What are you actually trying to do with this explicit wait?
You could use a pre-defined Expected Condition:
The reason you are having problems is that you are trying to create a new instance of a Function which is an interface, you can't do that. You could refactor the above ExpectedCondition into:
It looks quite close to your attempt, but it's not very readable or reusable. I would suggest that you create your own helper class with your own expected conditions in that looks like the standard ExpectedConditions class supplied by Selenium.