Skip to content
Advertisement

Is it a bug in Selenium documentation?

Here is the snippet from the new Selenium doc on Waits:

WebDriver driver = new ChromeDriver();
driver.get("https://google.com/ncr");
driver.findElement(By.name("q")).sendKeys("cheese" + Keys.ENTER);
// Initialize and wait till element(link) became clickable - timeout in 10 seconds
WebElement firstResult = new WebDriverWait(driver, Duration.ofSeconds(10))
        .until(ExpectedConditions.elementToBeClickable(By.xpath("//a/h3")));

When I paste this code, it gives me an error on the Duration: The constructor WebDriverWait(WebDriver, Duration) is undefined

It still works with the following syntax:

WebElement firstResult = new WebDriverWait(driver, 10)
                .until(ExpectedConditions.elementToBeClickable(By.xpath("//a/h3")));

Is it the documentation bug?

Advertisement

Answer

As I wrote in the original question,

WebElement firstResult = new WebDriverWait(driver, 10)
                .until(ExpectedConditions.elementToBeClickable(By.xpath("//a/h3")));

the code above still works. I guess, as @Fenio assumed, the new syntax will be available in Selenium 4 since it exists in the GitHub.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement