Duration cannot be resolved or is not a field in WebDriverwait in Selenium

1.4k Views Asked by At

I am trying to interact with a calendar on a webpage, so I am using WebDriver wait.

Below is the method:

new WebDriverWait(driver,Duration.ofSeconds(5)).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.className("calendar")));

Is something wrong here? The errors are shown as:

Multiple markers at this line
    - Duration cannot be resolved or is not a field
    - Syntax error on token ",", . expected
    - The constructor WebDriverWait(WebDriver, Duration) is 
     undefined

what is wrong here?

1

There are 1 best solutions below

0
On

To resolve the Duration issue :

import java.time.Duration;

import this at the top, "Duration" got resolved it worked for me.