SessionNotCreatedException:消息:会话未从断开连接创建:无法使用ChromeDriver 2.45 Chrome v71连接到渲染器 [英] SessionNotCreatedException: Message: session not created from disconnected: unable to connect to renderer with 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 无法启动/产生新的 WebBrowser ,即 Chrome浏览器会话.
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
您需要考虑一个事实:
-
在使用 Mac OS X 时,必须使用 Value 来支持 Key
executable_path
:
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')
注意:路径本身是原始路径,因此您无需添加开关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屋!