1

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?

3
  • Update the question with the code. Apr 6, 2022 at 5:55
  • i added links to the images
    – Ahat
    Apr 6, 2022 at 6:49
  • 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.
    – cigien
    May 18, 2022 at 16:57

3 Answers 3

7

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.

0
1
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));
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.

1
  • says "Only a type can be imported. org.openqa.selenium.support.ui resolves to a package"
    – Ahat
    Apr 6, 2022 at 6:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.