WebDriverWait is deprecated in Selenium 4

Mate Mrše picture Mate Mrše · Nov 22, 2019 · Viewed 37.6k times · Source

I'm getting a

Warning: (143,13) 'WebDriverWait(org.openqa.selenium.WebDriver, long)' is deprecated

in Selenium 4.0.0-alpha-3.

But official Selenium page lists only

WebDriverWait(WebDriver driver, Clock clock, Sleeper sleeper, long timeOutInSeconds, long sleepTimeOut)

as deprecated.

What is wrong? I'm using IntelliJ, could it be their issue?

Answer

Guy picture Guy · Dec 4, 2019

It doesn't appear in the docs, but if you look at the source code you will see @Deprecated annotation

@Deprecated
public WebDriverWait(WebDriver driver, long timeoutInSeconds) {
    this(driver, Duration.ofSeconds(timeoutInSeconds));
}

In the constructor description you have the solution

@deprecated Instead, use {@link WebDriverWait#WebDriverWait(WebDriver, Duration)}.

Which is the constructor being called from the deprecated one in any case.

new WebDriverWait(driver, Duration.ofSeconds(10));