SessionNotCreatedException:消息:会话未从断开连接创建:无法使用 ChromeDriver 2.45 Chrome v71 连接到渲染器 [英] SessionNotCreatedException: Message: session not created from disconnected: unable to connect to renderer with ChromeDriver 2.45 Chrome v71

查看:31
本文介绍了SessionNotCreatedException:消息:会话未从断开连接创建:无法使用 ChromeDriver 2.45 Chrome v71 连接到渲染器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 Python 使用 Selenium 执行此代码时:

When I'm executing this code with Selenium using Python:

from selenium import webdriver
from selenium.webdriver.common.by import By
import time
driver = webdriver.Chrome(executable_path=r'/Users/qa/Documents/Python/chromedriver')

发生错误:

   Traceback (most recent call last):
  File "/Users/qa/Documents/Python/try.py", line 4, in <module>
    driver = webdriver.Chrome(executable_path=r'/Users/qa/Documents/Python/chromedriver')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from disconnected: unable to connect to renderer
  (Session info: chrome=71.0.3578.98)
  (Driver info: chromedriver=2.44.609545 (c2f88692e98ce7233d2df7c724465ecacfe74df5),platform=Mac OS X 10.13.6 x86_64)

有人可以帮助我吗?谢谢.

Can someone help me? Thanks.

推荐答案

这个错误信息...

selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from disconnected: unable to connect to renderer

...暗示 ChromeDriver 无法启动/生成新的 WebBrowserChrome 浏览器 会话.

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

你需要考虑一个事实:

  • 当您使用 Mac OS X 时,Key executable_path 必须由 Value 支持如:

  • As you are using Mac OS X the Key executable_path must be supported with a Value as :

'/Users/qa/Documents/Python/chromedriver'

  • 所以行将是:

  • So line will be:

    driver = webdriver.Chrome(executable_path='/Users/qa/Documents/Python/chromedriver')
    

  • 注意:path 本身是一个原始路径,因此您不需要添加开关 r 并删除它.

    Note: The path itself is a raw path so you don't need to add the switch r and drop it.

    此外,请确保您系统上的 /etc/hosts 包含以下条目:

    Additionally, ensure that /etc/hosts on your system contains the following entry :

    127.0.0.1 localhost.localdomain localhost
    #or
    127.0.0.1 localhost loopback
    

    这篇关于SessionNotCreatedException:消息:会话未从断开连接创建:无法使用 ChromeDriver 2.45 Chrome v71 连接到渲染器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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