Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 IE。当我使用命令 driver.quit() 或 driver.close() 关闭浏览器时,会弹出一个警告框说“你想离开网页吗?” 那么当我退出 WebDriver 时如何接受警告框。
尝试接受警报时,我得到会话不存在异常。
谢谢。
在调用 driver.quit() 或 driver.close() 之前使用 java 脚本将窗口onbeforeunload处理程序设置为 null
window.onbeforeunload = null;
尝试切换到警报,然后接受。这就是它在 ruby 代码中的样子。
driver.switch_to.alert.accept
爪哇:
Alert alert = driver.switchTo().alert(); alert.accept();