测试失败后如何关闭 IE windows

How to close IE windows after failed test

我正在使用 Selenide(Selenium 包装器)+ TestNG。当测试失败时,Selenide 尝试关闭所有 windows(据我了解),但当它发生时出现模式对话框("confirm quit from page"),Selenide 无法关闭打开的问题 windows...(不是任务管理器中的几个IEdrivers)我尝试通过多种变体接受这个模式对话框,但没有成功。

请指教,如何处理这个模态对话框并在测试失败后关闭打开windows?

试试

DesiredCapabilities 能力 = new DesiredCapabilities(); capabilities.setCapability("ignoreProtectedModeSettings", 真); capabilities.setCapability(CapabilityType.UNHANDLED_PROMPT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE); WebDriver 驱动程序 = new InternetExplorerDriver(capabilities);

解决方案是通过此命令在任务管理器中终止所有 IE 进程

Runtime.getRuntime().exec("taskkill /F /IM iexplore.exe");