How to remove deprecation warning on timeout and polling in Selenium Java Client v3.11.0
@Grasshopper 's answer points us to the exact modified constructor of FluentWait and your requirement of removing the deprecation warning from withTimeout and pollingEvery fields. Incase you are facing further difficulty you can use the line of code below :
import java.time.Duration;
//lines of code
Wait<WebDriver> gWait = new FluentWait<WebDriver>(pDriver).withTimeout(Duration.ofSeconds(100))
.pollingEvery(Duration.ofMillis(600)).ignoring(NoSuchElementException.class);
You can find a detailed discussion in The type FluentWait is not generic; it cannot be parameterized with arguments error for FluentWait Class through Selenium and Java
Check the source code of FluentWait which mentions to use the methods using Duration as arguments instead.
- withTimeout - Use the
withTimeout(Duration duration)
method. - pollingEvery - Use the
pollingEvery(Duration duration)
method.
you can use following lines of code:
Wait<Browser> wait = new FluentWait<>(driver)
.withTimeout(Duration.ofSeconds(*timeToWaitInSec*))
.pollingEvery(Duration.ofMillis(*TimeToTryinMillisec*))
.ignoring(WebDriverException.class);