码:

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement btn = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@class='_1vp5 f_click']")));
btn.click();


错误:


  系统信息:主机:'ADMIN-PC',ip:'192.168.1.6',操作系统名称:'Windows 10',os.arch:'x86',os.version:'10 .0',java.version:'1.8 .0_144'
  驱动程序信息:driver.version:未知
      在org.openqa.selenium.support.ui.ExpectedConditions.lambda $ findElement $ 0(ExpectedConditions.java:882)
      在java.util.Optional.orElseThrow(未知源)
      在org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:881)
      在org.openqa.selenium.support.ui.ExpectedConditions.access $ 000(ExpectedConditions.java:43)
      在org.openqa.selenium.support.ui.ExpectedConditions $ 7.apply(ExpectedConditions.java:205)
      在org.openqa.selenium.support.ui.ExpectedConditions $ 7.apply(ExpectedConditions.java:201)
      在org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
      ...还有1个

最佳答案

该代码现在可以正常工作:

WebElement btn = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@class='_1vp5']")));

10-06 02:22