【问题标题】:WebDriverWait wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(by)) not working with Selenium 3.4.0WebDriverWait wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(by)) 不适用于 Selenium 3.4.0
【发布时间】:2017-05-11 22:00:28
【问题描述】:
WebDriverWait wait = new WebDriverWait(driver, timoutInSeconds);
List<WebElement> elements = 
wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(by));

它是一个 maven 项目,我已经从 2.53.0 升级到 selenium 3.4.0 版本,并添加了 21.0 版本的番石榴依赖项。 早些时候所有的等待都在工作。当升级到最新的 selenium 3.4.0 版本时,所有的等待都被打破了。执行测试时收到以下错误。

java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Ljava/util/function/Function;)Ljava/lang/Object;

许多用户说添加 Guava 依赖这个问题不再存在,但即使添加 Guava 依赖后我也看到了这个问题。

【问题讨论】:

  • 这里是添加的 maven 依赖项 com.google.guavaguava21.0org.seleniumhq.seleniumselenium-java3.4.0编译
  • 1) 你先运行mvn clean 了吗? 2) 在 cmets 中发布您的整个 pom.xml - 并且,但要编辑您的原始帖子。

标签: java selenium selenium-webdriver


【解决方案1】:

看这个WebDriverWait.until no longer available in Selenium-java-3.2 and Selenium-java-3.3 releases的第三条评论

我添加了番石榴依赖 + 现在使用流利的等待,它工作正常

【讨论】:

  • 我试过它不起作用。添加了 Guava 依赖项并更新了如下代码,但错误仍然相同。 Wait wait = new FluentWait(driver) .withTimeout(timoutInSeconds, TimeUnit.SECONDS) .pollingEvery(5, TimeUnit.SECONDS) .ignoring(NoSuchElementException.class); WebElement foo = wait.until(new Function() { public WebElement apply(WebDriver driver) { return driver.findElement(by); } });
  • 也试过这个。仍然相同的错误 final WebElement element = (new WebDriverWait(driver, 10)).until(new ExpectedCondition() { @Override public WebElement apply( final WebDriver d) { WebElement weReturn = null; final WebElement bodyText = driver.findElement (by); if (bodyText != null) { weReturn = bodyText; } return weReturn; } });
猜你喜欢
  • 2016-03-19
  • 2021-08-26
  • 2018-08-25
  • 2015-03-04
  • 1970-01-01
  • 2019-01-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多