The constructor WebDriverWait(chromeDriver, int) is undefined [closed]
Asked Answered
R

3

6

WebDriverWait is not recognized even though it is imported in the eclipse IDE.

enter image description here

Does anyone know the possible reason and fix for this?

Reikoreilly answered 6/4, 2022 at 4:30 Comment(3)
Update the question with the code.Boiling
i added links to the imagesReikoreilly
Please add code and data as text (using code formatting), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and many more reasons. Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data.Beneficiary
B
12

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.

Boiling answered 6/4, 2022 at 6:57 Comment(0)
H
4
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));
Humidify answered 14/5, 2022 at 14:26 Comment(0)
T
0

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.

Teena answered 6/4, 2022 at 4:54 Comment(1)
says "Only a type can be imported. org.openqa.selenium.support.ui resolves to a package"Reikoreilly

© 2022 - 2024 — McMap. All rights reserved.