[英]selenium.common.exceptions.WebDriverException: Message: chrome not reachable error while using find_element_by_id Selenium with ChromeDriver
Here is the html code:这是 html 代码:
< input class="form-control input-lg input auto-complete" id="ymMsgInput" type="text" placeholder="Type your message ..." autocomplete="off" >
Code:代码:
i = s.find_element_by_id("ymMsgInput");
Python - Selenium Chrome webdriver error: Python - Selenium Chrome webdriver错误:
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
i = s.find_element_by_id("ymMsgInput");
File "C:\Users\vishn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 351, in find_element_by_id
return self.find_element(by=By.ID, value=id_)
File "C:\Users\vishn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 955, in find_element
'value': value})['value']
File "C:\Users\vishn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:\Users\vishn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
(Session info: chrome=65.0.3325.146)
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 10.0.16299 x86_64)
The error says it all :错误说明了一切:
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
This error is observed in case of version compatibility between the binaries which an user uses but definitely this is not your case as you are :如果用户使用的二进制文件之间存在版本兼容性,则会观察到此错误,但绝对不是您的情况:
Selenium version unknown硒版本未知
Release Notes of chromedriver=2.36 clearly mentions : chromedriver=2.36 的发行说明清楚地提到:
Supports Chrome v65-66
But, since the release of the latest Chromedriver 2.36 Selenium users had been facing issues with it.但是,自从最新的Chromedriver 2.36 Selenium发布以来,用户一直面临着它的问题。 Here is one of the threads :
这是其中一个线程:
The root cause is related to the commit regarding :根本原因与提交有关:
Remove --disable-infobars 删除 --disable-infobars
So, a couple of possible solution will be to :因此,几个可能的解决方案是:
To use ChromeOptions Class to maximize the browser.使用ChromeOptions类来最大化浏览器。
disable-infobars
disable-infobars
An example :一个例子:
from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument("start-maximized") driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\\path\\to\\chromedriver.exe') driver.get('https://www.google.co.in') print("Page Title is : %s" %driver.title)
If your issue still persists consider the following :如果您的问题仍然存在,请考虑以下事项:
Test
.Test
。Your exception is not about finding an element.您的例外与查找元素无关。 Selenium is not able to contact Chrome.
Selenium 无法联系 Chrome。 You can do couple of things.
你可以做几件事。
Downgrade/upgrade your chromedriver based on your selenium version.根据您的 selenium 版本降级/升级您的 chromedriver。
Pass --no-sandbox to chrome options.将 --no-sandbox 传递给 chrome 选项。
chrome_options.add_argument('--no-sandbox') chrome = webdriver.Chrome('/usr/local/bin/chromedriver', chrome_options=chrome_options)
In addition to the version issues mentioned above (eg, pip uninstall chromedriver-binary and re-install a different version with pip install chromedriver-binary==104.0.5112.20, for example):除了上面提到的版本问题(例如,pip 卸载 chromedriver-binary 并使用 pip install chromedriver-binary==104.0.5112.20 重新安装不同的版本):
Leave the browser window open after running 'driver = webdriver.Chrome()' in Python.在 Python 中运行“driver = webdriver.Chrome()”后,让浏览器 window 保持打开状态。 Closing it will interfere with subsequent lines using driver.get().
关闭它会干扰使用 driver.get() 的后续行。
As I found out it could also be the settings or the launch itself of a VPN.正如我发现的那样,它也可能是 VPN 的设置或启动本身。 Please make sure to check if the same problem occurs without browsing through VPN.
请务必检查是否在不通过 VPN 浏览的情况下发生相同的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.