在我的测试脚本中必须为每次执行写waiFor(5),否则测试失败。 我正在使用POM,并且有单独的类。
@Test(priority=2)
public void TestMedical() throws InterruptedException {
waitFor(5);
MedicalPage medicalpage = new MedicalPage(driver);
waitFor(5);
medicalpage.PhysicianName(Repo.getProperty("fName"));
medicalpage.seteditableLastName(Repo.getProperty("lName"));
waitFor(5);
medicalpage.setPhone(Repo.getProperty("Phone"));
waitFor(5);
medicalpage.setEmail(Repo.getProperty("Email"));
}
这是我的登录页面(对象) -
// Created methods in this page, and using Testng trying to call all the below methods. But getting failure message Unable to Locate Element, If there is no wait time watFor(5). With Wait time its running fine.In base page have explicit wait time method, but its not working. After input the data in text field when i click on submit button page is doing some Java Script or Ajax.
Ajax调用最多需要60秒。
driver.findElement(firstName).click();
driver.findElement(editableFirstName).clear();
driver.findElement(editableFirstName).click();
driver.findElement(editableFirstName).sendKeys(fName);
}
答案 0 :(得分:0)
添加了try-catch,现在运行正常
WebElement element = driver.findElement(XYZ);
boolean clicked = false;
do{
try {
element.click();
} catch (WebDriverException e) {
continue;
} finally {
clicked = true;
}
} while (!clicked);;