如何解决处理警报并等待后,页面未加载并且无法找到元素 硒中
处理警报并等待(运行时弹出窗口,)后,页面未加载,这就是找不到元素的原因。 (在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();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。