[英]Getting an error org.openqa.selenium.WebDriverException disconnected: received Inspector.detached event with Selenium ChromeDriver and Chrome
I am trying to run my automation script using selenium and Java and facing an error as: 我正在尝试使用selenium和Java运行自动化脚本,并遇到如下错误:
WebDriverException: Message: disconnected: received Inspector.detached event
(Session info: chrome=76.0.3809.100)
(Driver info: chromedriver=76.0.3809.126 (d80a294506b4c9d18015e755cee48f953ddc3f2f-refs/branch-heads/3809@{#1024})
Can someone explain me the error please? 有人可以向我解释错误吗?
This error message... 此错误消息...
WebDriverException: Message: disconnected: received Inspector.detached event
...implies that the ChromeDriver was automatically disconnected when the test execution was In Progress . ......意味着,当测试执行的执行过程中ChromeDriver已自动断开连接。
In the article DevTools window keeps closing it is clearly mentioned that if you try to open the DevTools window when the ChromeDriver is busy executing automated tests , the ChromeDriver automatically gets disconnected and when ChromeDriver receives a command in disconnected state, it will attempt to close the DevTools window and reconnect back. 在DevTools窗口保持关闭的文章中,明确提到如果您在ChromeDriver忙于执行自动化测试时尝试打开DevTools窗口,则ChromeDriver会自动断开连接,并且当ChromeDriver收到处于断开状态的命令时,它将尝试关闭DevTools窗口并重新连接回去。 Earlier Chrome's DevTools allowed only one debugger per page.
较早的Chrome的DevTools每页只允许一个调试器。 But since ChromeDriver v2.x, it is now a DevTools debugging client.
但是从ChromeDriver v2.x开始,它现在已成为DevTools调试客户端。
If your usecase is to inspect the DOM Tree through the DevTools, the best approach would be to pause your test execution so that ChromeDriver won't close the DevTools. 如果您的用例是通过DevTools检查DOM树 ,则最好的方法是暂停测试执行,以使ChromeDriver不会关闭DevTools。 When you complete inspecting HTML DOM through Chrome, you can unpause your test and ChromeDriver will close the window and continue.
通过Chrome检查完HTML DOM后 ,您可以取消暂停测试,ChromeDriver将关闭该窗口并继续。
As per the discussion in unknown error: cannot determine loading status from disconnected: received Inspector.detached placing the ChromeDriver in path solves the issue. 根据有关未知错误的讨论:无法确定断开连接的加载状态:收到Inspector.detached将ChromeDriver放置在路径中即可解决此问题。 So you need to:
因此,您需要:
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
driver.get("https://google.com")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.