selenium - Selenium IE11 警报弹出句柄不适用于关闭浏览器弹出窗口
问题描述
问题: 我将 IE11 与 Selenium Webdriver 一起使用,当我尝试关闭 IE 浏览器时,我得到一个“来自网页的消息”弹出显示,我试图单击“确定”但警报句柄不起作用,它没有单击“好的”。
Selenium 版本:3.12.0 IEDriverServer(32 位)版本:3.12.0
public void selectReqFolder() throws Exception {
windowHandle = new WindowsHandle();
//Clicking here open new child window
driver.findElement(Contract_File_Action_Copy_Frwd_Trnsction_button_Solcitation_Link).click();
//Window handle method, switch focus on to child window and does all the task in there
windowHandle.windowsHandle();
//Using window handles to switch to parent window
Set<String> s1 = driver.getWindowHandles();
// Now we will iterate using Iterator to go over the totoal windows
Iterator<String> I1 = s1.iterator();
// List of the windows
String parent = I1.next();
String child_window = I1.next();
**[![// Here we will compare if parent window
driver.switchTo().window(parent);
//Closing the broswer
driver.close();
Thread.sleep(4000);
//Handeling Alert
Alert alert = driver.switchTo().alert();
// Capturing alert message.
String alertMessage= driver.switchTo().alert().getText();
//To click on OK button of the alert
driver.switchTo().alert().accept();][1]][1]**
}
解决方案
推荐阅读
- unix - 从目录中复制文件中包含特定句子的前 100 个文件
- c++ - Boost Process 1.71 不再查看环境路径
- javascript - TypeError: undefined is not a function ('...this.state.profile.map...'附近)
- math - 将平面从点/法线/D 转换为平面方程
- react-native - flowtype 插件影响代码的其他部分
- sql - 删除字符串 SQL 中的电子邮件地址
- flutter - 如何在颤动中限制 GridView 小部件的宽度
- sas - SAS - 如何配置 sas 以使用本地磁盘而非本地磁盘 C 中的资源:
- css - 如何在 Vue 中定位固定的子元素?
- jquery - Array.map() 产生奇怪的结果