SUM*_*SUM 2 selenium selenium-webdriver
我试图在测试脚本中的每个web元素之前添加显式等待
我的代码有
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
.
.
WebDriverWait wait = new WebDriverWait(driver, 60);
wait.until(presenceOfElementLocated(By.id("name")));
driver.findElement(By.id("name")).clear();
driver.findElement(By.id("name")).sendKeys("Create_title_01");
Run Code Online (Sandbox Code Playgroud)
我看到的错误是:
java.lang.NullPointerException
at org.openqa.selenium.support.ui.FluentWait$1.apply(FluentWait.java:176)
at org.openqa.selenium.support.ui.FluentWait$1.apply(FluentWait.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:201)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:174)
Run Code Online (Sandbox Code Playgroud)
谢谢
用于使用presenceOfElementLocated和其他AjaxCondition方法
你应该使用
org.openqa.selenium.support.ui.ExpectedConditions
类.你的代码应该是这样的:
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("name")));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5744 次 |
| 最近记录: |