selenium.common.exceptions.WebDriverException:消息:chrome 无法访问错误,同时使用 find_element_by_id Selenium 和 ChromeDriver [英] selenium.common.exceptions.WebDriverException: Message: chrome not reachable error while using find_element_by_id Selenium with ChromeDriver

查看:35
本文介绍了selenium.common.exceptions.WebDriverException:消息:chrome 无法访问错误,同时使用 find_element_by_id Selenium 和 ChromeDriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是html代码:

< input class="form-control input-lg input auto-complete" id="ymMsgInput" type="text" placeholder="Type your message ..." autocomplete="off" >

代码:

i = s.find_element_by_id("ymMsgInput");

Python - Selenium Chrome 网络驱动程序错误:

Python - Selenium Chrome webdriver error:

Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    i = s.find_element_by_id("ymMsgInput");
  File "C:UsersvishnAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver
emotewebdriver.py", line 351, in find_element_by_id
    return self.find_element(by=By.ID, value=id_)
  File "C:UsersvishnAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver
emotewebdriver.py", line 955, in find_element
    'value': value})['value']
  File "C:UsersvishnAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver
emotewebdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "C:UsersvishnAppDataLocalProgramsPythonPython36-32libsite-packagesseleniumwebdriver
emoteerrorhandler.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)

推荐答案

错误说明了一切:

    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 :

  • 使用 chromedriver=2.36
  • 使用 chrome=65.0
  • Selenium 版本未知

chromedriver=2.36 的发布说明中明确提到:

Release Notes of chromedriver=2.36 clearly mentions :

支持 Chrome v65-66

但是,自从发布最新的 Chromedriver 2.36 Selenium 用户一直面临着它的问题.这是其中一个线程:

But, since the release of the latest Chromedriver 2.36 Selenium users had been facing issues with it. Here is one of the threads :

根本原因与提交有关:

因此,几个可能的解决方案是:

So, a couple of possible solution will be to :

使用 ChromeOptions 类来最大化浏览器.

To use ChromeOptions Class to maximize the browser.

一个例子:

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	ochromedriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)

如果您的问题仍然存在,请考虑以下事项:

If your issue still persists consider the following :

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

这篇关于selenium.common.exceptions.WebDriverException:消息:chrome 无法访问错误,同时使用 find_element_by_id Selenium 和 ChromeDriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆