1
    WebDriver driver = new ChromeDriver();
    WebDriverWait w =new WebDriverWait(driver,5);

I am getting an error for the second line. the error is "The constructor WebDriverWait(WebDriver,int) is undefined"

Can someone please help me out here?

I tried to initialize the webdriver wait class. I foollowed the syntax as instructed but I am getting an error.

sound wave
  • 3,191
  • 3
  • 11
  • 29
Andromeda
  • 11
  • 1
  • 1
    Does this answer your question? [The constructor WebDriverWait(chromeDriver, int) is undefined](https://stackoverflow.com/questions/71761074/the-constructor-webdriverwaitchromedriver-int-is-undefined) – dinhit Mar 01 '23 at 03:22

1 Answers1

0

You must be using latest Selenium 4.xx , you should do it like this

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));

The constructor which accepted wait time in long has been depreciated in version 4 and is removed in the latest releases

   @Deprecated
  public WebDriverWait(WebDriver driver, long timeoutInSeconds) {
    this(driver, Duration.ofSeconds(timeoutInSeconds));
  }
Abhay Chaudhary
  • 1,763
  • 1
  • 8
  • 13