gpt4 book ai didi

python - Chrome 的 Selenium 驱动程序在 Python 中抛出 WebDriverException

转载 作者:行者123 更新时间:2023-12-01 03:36:46 25 4
gpt4 key购买 nike

我在 Python 中运行以下命令来实例化适用于 Chrome 的 Selenium Webdriver,但出现异常。以前(几天前)没有错误:

from selenium import webdriver
driver = webdriver.chrome.webdriver.WebDriver()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 65, in __init__
keep_alive=True)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 74, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 123, in start_session
'desiredCapabilities': desired_capabilities,
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 175, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 166, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"aux
Data":{"frameId":"9716.1","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=54.0.2840.71)
(Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc
1b),platform=Windows NT 6.1.7601 SP1 x86_64)

还有以下形式的错误:

  File "C:\Python27\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 67, in __init__
desired_capabilities=desired_capabilities)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 87, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 141, in start_session
'desiredCapabilities': desired_capabilities,
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 199, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 395, in execute
return self._request(command_info[0], url, body=data)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 426, in _request
resp = self._conn.getresponse()
File "C:\Python27\lib\httplib.py", line 1132, in getresponse
response.begin()
File "C:\Python27\lib\httplib.py", line 453, in begin
version, status, reason = self._read_status()
File "C:\Python27\lib\httplib.py", line 409, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "C:\Python27\lib\socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
socket.error: [Errno 10054] An existing connection was forcibly closed by the remote host

最佳答案

我通过将 Chromedriver.exe 升级到 2.25 解决了该问题:http://chromedriver.storage.googleapis.com/index.html?path=2.25/

(很可能 Chrome 版本已自动更新,这也需要更新 Chromedriver。)

关于python - Chrome 的 Selenium 驱动程序在 Python 中抛出 WebDriverException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40258366/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com