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

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

问题描述

这是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 Webdriver错误:

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:\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)

推荐答案

错误说明了一切:

    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
  • 硒版本未知

  • Using chromedriver=2.36
  • Using chrome=65.0
  • Selenium version unknown

chromedriver = 2.36 的发行说明明确提到:

Release Notes of chromedriver=2.36 clearly mentions :

Supports Chrome v65-66

但是,自最新版 Chromedriver 2.36 发布以来

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

根本原因与有关的提交有关:

The root cause is related to the commit regarding :

因此,可能有两种解决方案:

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\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 :

  • Selenium Python客户端升级到当前级别版本3.10.0 .
  • ChromeDriver 升级到稳定 根据ChromeDriver v2.35发行说明)
  • 通过 IDE
  • 清理您的项目工作区重建您的项目,并且仅具有必需的依赖项.
  • 使用 CCleaner 工具清除之前和之后的所有操作系统杂项在执行 test Suite 之后.
  • 如果您的基本 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与ChromeDriver一起使用find_element_by_id Selenium时无法访问错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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