How to fix WebDriverWait deprecated message in Selenium tests?
Overview
In this tutorial, we will see how to fix the WebDriverWait deprecated warning message in Selenium tests. The constructor WebDriverWait(WebDriver, long) is deprecated now in the Selenium framework.
Deprecated Code
So the declaration of web driver wait of this form would appear strikes in the test automation code.
WebDriverWait wait = newWebDriverWait(driver, 120);
The long parameter 120 is the timeout specified in seconds. This makes the driver instance to wait
waiting until an expected condition is true or not null in the web tests.
Fix
To fix the warning message, we need to pass the timeout as a Duration class. In most cases Duration class models time in seconds and in nanoseconds.
To fix the selenium tests we should use:
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(120, 1));
Selenium WebDriver Tutorials on this website can be found at:
https://www.testingdocs.com/selenium-webdriver-tutorial
For more details on the Selenium, visit the official website at: