WebDriverWait is not recognized even though it is imported in the eclipse IDE.
Does anyone know the possible reason and fix for this?
WebDriverWait is not recognized even though it is imported in the eclipse IDE.
Does anyone know the possible reason and fix for this?
You are trying to use
new WebDriverWait(driver, 10);
which will call this constructor
/**
* Wait will ignore instances of NotFoundException that are encountered (thrown) by default in
* the 'until' condition, and immediately propagate all others. You can add more to the ignore
* list by calling ignoring(exceptions to add).
*
* @param driver The WebDriver instance to pass to the expected conditions
* @param timeoutInSeconds The timeout in seconds when an expectation is called
* @see WebDriverWait#ignoring(java.lang.Class)
* @deprecated Instead, use {@link WebDriverWait#WebDriverWait(WebDriver, Duration)}.
*/
@Deprecated
public WebDriverWait(WebDriver driver, long timeoutInSeconds) {
this(driver, Duration.ofSeconds(timeoutInSeconds));
}
As you can see, it has been deprecated in newer version of Selenium i.e Selenium 4
Solution:
You should rather use this constructor:
public WebDriverWait(WebDriver driver, Duration timeout) {
this(
driver,
timeout,
Duration.ofMillis(DEFAULT_SLEEP_TIMEOUT),
Clock.systemDefaultZone(),
Sleeper.SYSTEM_SLEEPER);
}
Your effective code:
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
should get the job done for you.
WebDriverWait w=new WebDriverWait(driver,10)
basically, this is deprecated.
This issue can be suppressed by changing the above statement in the following ways
WebDriverWait webdwait = new WebDriverWait(driver, Duration.ofSeconds(10));
WebDriverWait webdwait = new WebDriverWait(driver, Duration.ofHours(10));
WebDriverWait is missing from your project. 1.Check you have used the import the statement org.openqa.selenium.support.ui 2. Either add the jar manually to the project (or) if it is Maven based project use mvn clean install , and reopen the IDE- you should be good.
© 2022 - 2024 — McMap. All rights reserved.