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?
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));
Write it like this with Selenium 4 since what you tried to use is deprecated, as you said. First import.
import java.time.Duration;
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
driver.manage().timeouts().scriptTimeout(Duration.ofSeconds(30));
driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(60));
For fluent wait.
Wait<WebDriver> wait= new FluentWait<WebDriver>(driver)
.withTimeout(Duration.ofSeconds(30))
.pollingEvery(Duration.ofSeconds(5))
.ignoring(NoSuchElementException.class);
WebDriverWait statement
WebDriverWait wait = new WebDriverWait(driver,Duration.ofSeconds(10));
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
Use this instead, only WebDriverWait(driver, clock) is supported;
Code which gives the below warning:
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
Warning:
The method implicitlyWait(long, TimeUnit)
from the type WebDriver.Timeouts
is deprecated.
Update which works on selenium4:
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With