简体   繁体   English

selenium.common.exceptions.WebDriverException:消息:使用 find_element_by_id Selenium 和 ChromeDriver 时出现 chrome 无法访问错误

[英]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 :如果用户使用的二进制文件之间存在版本兼容性,则会观察到此错误,但绝对不是您的情况:

  • Using chromedriver=2.36使用chromedriver=2.36
  • Using chrome=65.0使用chrome=65.0
  • 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类来最大化浏览器。

  • Remove the option 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 :如果您的问题仍然存在,请考虑以下事项:

  • Upgrade Selenium Python Client to current levels Version 3.10.0 .Selenium Python 客户端升级到当前级别版本 3.10.0
  • Upgrade ChromeDriver to stable ChromeDriver v2.35 level.升级ChromeDriver稳定ChromeDriver v2.35水平。
  • Keep Chrome version at Chrome v64.x levels.Chrome版本保持在Chrome v64.x级别。 ( as per ChromeDriver v2.35 release notes ) 根据 ChromeDriver v2.35 发行说明
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.通过IDE清理项目工作区并仅使用所需的依赖项重建项目。
  • Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite .在执行测试套件之前和之后,使用CCleaner工具清除所有操作系统杂务。
  • If your base Chrome version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Chrome.如果您的基本Chrome版本太旧,请通过Revo Uninstaller卸载它并安装最新的 GA 和已发布版本的 Chrome。
  • Execute your 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.你可以做几件事。

  1. Downgrade/upgrade your chromedriver based on your selenium version.根据您的 selenium 版本降级/升级您的 chromedriver。

  2. 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.

相关问题 selenium.common.exceptions.WebDriverException: Message: invalid session id using Selenium with ChromeDriver and Chrome through Python - selenium.common.exceptions.WebDriverException: Message: invalid session id using Selenium with ChromeDriver and Chrome through Python python, selenium, chromedriver &#39;selenium.common.exceptions.WebDriverException: 消息:无法访问 u&#39;chrome - python, selenium, chromedriver 'selenium.common.exceptions.WebDriverException: Message: u'chrome not reachable selenium.common.exceptions.WebDriverException: 消息:无法通过 Selenium Python 使用 ChromeDriver Chrome 连接到服务错误 - selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service error using ChromeDriver Chrome through Selenium Python &#39;selenium.common.exceptions.WebDriverException:消息:u&#39;chrome无法访问 - 'selenium.common.exceptions.WebDriverException: Message: u'chrome not reachable selenium.common.exceptions.WebDriverException:消息:无法访问chrome - selenium.common.exceptions.WebDriverException: Message: chrome not reachable selenium.common.exceptions.WebDriverException:消息:未知错误:无法使用 ChromeDriver Chrome Selenium 创建 Chrome 进程错误 - selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create a Chrome process error with ChromeDriver Chrome Selenium selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome无法启动:使用ChromeDriver Chrome和Selenium异常退出 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium selenium.common.exceptions.WebDriverException:消息:未知错误:无法使用带有Selenium Python的ChromeDriver Chrome创建Chrome进程 - selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create Chrome process with ChromeDriver Chrome with Selenium Python selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome 无法启动:在 Python 中使用 ChromeDriver 和 Selenium 崩溃 - selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed with ChromeDriver and Selenium in Python selenium.common.exceptions.WebDriverException:消息:打开chrome浏览器时无法连接到服务chromedriver.exe - selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service chromedriver.exe while opening chrome browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM