Java >> Java チュートリアル >  >> Java

Selenium ドキュメントのバグですか?

Waits に関する新しい Selenium ドキュメントのスニペットは次のとおりです。

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")));

このコードを貼り付けると、Duration に関するエラーが表示されます:The constructor WebDriverWait(WebDriver, Duration) is undefined

次の構文でも機能します:

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

ドキュメントのバグですか?

答え

元の質問に書いたように、

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

上記のコードは引き続き機能します。 @Fenio が想定していたように、新しい構文は GitHub に存在するため、Selenium 4 で利用できるようになると思います。


Java タグ