首页 > 解决方案 > UnreachableBrowserException:与远程浏览器通信时出错。它可能已经死了,并且 Command 未能干净地关闭。强行破坏

问题描述

当我执行一个测试套件时,tearDown() 方法会随机失败,并且它下面的所有测试都会被跳过。以下是详细信息。附上屏幕截图。

测试跟踪:

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died. Build info: version: '2.46.0', revision: '61506a4624b13675f24581e453592342b7485d71', time: '2015-06-04 10:22:50' System info: host: 'W7-VDI-WDW704', ip: '10.207.15.35', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_152' Driver info: driver.version: RemoteWebDriver

日志:

INFO: Command failed to close cleanly. Destroying forcefully (v2). org.openqa.selenium.os.UnixProcess$SeleniumWatchDog@12c7a01b 
Oct 09, 2018 4:03:01 PM org.openqa.selenium.os.ProcessUtils killWinProcess WARNING: Process refused to die after 10 seconds, and couldn't taskkill it
org.openqa.selenium.os.ProcessUtils$ProcessStillAliveException: Timeout waiting for process to die at org.openqa.selenium.os.ProcessUtils.waitForProcessDeath(ProcessUtils.java:67) at (...)

Suite Total tests run: 196, Failures: 4, Skips: 175 Configuration Failures: 176, Skips: 175

在此处输入图像描述

标签: seleniumselenium-webdriverwebdriverselenium-chromedriverteardown

解决方案


此错误消息...

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died
.
INFO: Command failed to close cleanly. Destroying forcefully (v2). org.openqa.selenium.os.UnixProcess$SeleniumWatchDog@12c7a01b Oct 09, 2018 4:03:01 PM org.openqa.selenium.os.ProcessUtils killWinProcess WARNING: Process refused to die after 10 seconds, and couldn't taskkill it

...意味着ChromeDriver无法杀死WebBrowserRemoteWebDriver

您的主要问题是您使用的二进制文件版本之间的不兼容,如下所示:

根据在 Windows 上的讨论,RemoteWebDriver.quit() 总是强行破坏?这个问题在Selenium v​​2.45.0 之前的版本中很明显,@timja2 在他的评论中提到:

它预计在 Windows 上总是会破坏得更厉害

此修复程序通过提交 7a5e890合并,预计将从Selenium v​​2.53.1开始提供。

解决方案

  • 将Selenium升级到最低版本 2.53.1或当前级别的版本 3.14.0

推荐阅读