[英]selenium.common.exceptions.WebDriverException: Message: disconnected: received Inspector.detached event with ChromeDriver and Selenium through Python
I'm getting an error 我遇到错误
E
======================================================================
ERROR: test_01Login (__main__.LoginTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:/Users/amal/AppData/Local/Continuum/anaconda3/Lib/site-packages/Sucess/Test/Login_sj.py", line 29, in test_01Login
driver.get("https://google.com")
File "C:\Users\amal\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Users\amal\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\amal\AppData\Local\Continuum\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: disconnected: received Inspector.detached event
(Session info: chrome=76.0.3809.100)
----------------------------------------------------------------------
Ran 1 test in 8.615s
FAILED (errors=1)
while trying to automate a webpage using python 3.7 and selenium 3.141.0 尝试使用python 3.7和selenium 3.141.0自动化网页时
This is in windows 10. My java version is jdk-12.0.2 and chrome driver is ChromeDriver 76.0.3809.68 这是在Windows 10中。我的Java版本是jdk-12.0.2,Chrome驱动程序是ChromeDriver 76.0.3809.68
driver = webdriver.Chrome()
driver.get("https://google.com")
I'm new to Automation and learning by trial and error and excuse for any mistake as I just created this account and trying to post in any forum for the first time. 我是自动化的新手,通过反复试验和任何错误的借口学习,因为我刚刚创建了此帐户并尝试在任何论坛中首次发布。 I tried to reinstall Java, Chrome and tried multiple versions of chromedriver. 我尝试重新安装Java,Chrome,并尝试了多个版本的chromedriver。 Any help would be much appreciated. 任何帮助将非常感激。
This error message... 此错误消息...
WebDriverException: Message: disconnected: received Inspector.detached event
...implies that the ChromeDriver was automatically disconnected when you tried to open the DevTools window. ...表示您尝试打开DevTools窗口时, ChromeDriver已自动断开连接。
As per the article DevTools window keeps closing 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. 根据文章文章,如果您尝试在ChromeDriver忙于执行自动化测试时打开DevTools窗口,则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 you need 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=r'C:\path\to\chromedriver.exe')
driver.get("https://google.com")
PS: Ensure that you are using the latest ChromeDriver v76.0 and Chrome v76.0 . PS:确保您使用的是最新的ChromeDriver v76.0和Chrome v76.0 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.