处理警报并等待(运行时弹出,(后,页面未加载,这就是无法定位元素的原因。(在Selenium中(得到没有这样的元素:无法定位元素:
"公共类ApplicantLoginPageTest扩展了TestBase{
@Test
public void init() throws Exception {
ApplicantLoginPage applicantLoginPage = PageFactory.initElements(driver, ApplicantLoginPage.class);
applicantLoginPage.getApp(prop.getProperty("urlapp"));
Thread.sleep(3000);
applicantLoginPage.login(prop.getProperty("un"));
Thread.sleep(3000);
applicantLoginPage.instruct1();
Thread.sleep(3000);
applicantLoginPage.TestClick();
try {
WebDriverWait wait = new WebDriverWait(driver, 2);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.accept();
driver.switchTo().defaultContent();
} catch (Exception e) {
}
applicantLoginPage.TestCamera();
Thread.sleep(15000);
applicantLoginPage.PreviewRecord();
Thread.sleep(15000);
applicantLoginPage.instruct2();
Thread.sleep(3000);
}
}''''
删除以下语句,然后重试:
driver.switchTo().defaultContent();