gpt4 book ai didi

java - 这是 Selenium 文档中的错误吗?

转载 作者:行者123 更新时间:2023-12-01 18:02:01 25 4
gpt4 key购买 nike

以下是关于 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")));

当我粘贴此代码时,它在持续时间上给出错误:构造函数 WebDriverWait(WebDriver, Duration) 未定义

它仍然适用于以下语法:

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 所假设的那样,新语法将在 Selenium 4 中可用,因为它存在于 GitHub 中。

关于java - 这是 Selenium 文档中的错误吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60612671/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com