Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove deprecation warning on timeout and polling in Selenium Java Client v3.11.0

Below is my code which is showing as deprecated after I have been updated the Selenium Webdriver version to 3.11.0.

    private Wait<WebDriver> mFluentWait(WebDriver pDriver) {
    Wait<WebDriver> gWait = new FluentWait<WebDriver>(pDriver).withTimeout(100, TimeUnit.SECONDS)
            .pollingEvery(600, TimeUnit.MILLISECONDS).ignoring(NoSuchElementException.class);   
    return gWait;
}

Showing deprecated warning in withTimeout and pollingEvery section in the code.

How can I rewrite this code so that I can remove the deprecated warning.

Since am new to selenium am not sure about the change. Any help will be appreciated.

like image 631
kripindas Avatar asked Apr 06 '18 07:04

kripindas


People also ask

What is driver manage () timeouts () implicitlyWait?

1. implicitlyWait() This timeout is used to specify the amount of time the driver should wait while searching for an element if it is not immediately present.

How does Selenium handle connection timeout?

You should try to increase the timeout to ensure that the objects are available to selenium to work. If you want to handle the error, better include this code in @BeforeTest or @BeforeSuite annotation which ensure the entire test suite will not run if this fails.

What is timeout exception in Selenium?

In Selenium, TimeOut exception occurs when a command takes longer than the wait time to avoid the ElementNotVisible Exception. If the commands do not complete even after the wait time is over, a TimeOut Exception is thrown.

What is deprecated in Selenium?

selenium. internal package, is deprecated in Selenium 4. The changes are internal to the Selenium framework. Therefore, Selenium users can continue using the FindElement(By) and FindElements(By) as used in Selenium 3.


1 Answers

Check the source code of FluentWait which mentions to use the methods using Duration as arguments instead.

  1. withTimeout - Use the withTimeout(Duration duration) method.
  2. pollingEvery - Use the pollingEvery(Duration duration) method.
like image 95
Grasshopper Avatar answered Sep 21 '22 13:09

Grasshopper