提问人:harveyspecter 提问时间:8/23/2023 最后编辑:Peter Mortensenharveyspecter 更新时间:8/31/2023 访问量:456
错误:“无法从未创建的会话连接到 127.0.0.1:54613 的 chrome:此版本的 ChromeDriver 仅支持 Chrome 版本 114
Error : "cannot connect to chrome at 127.0.0.1:54613 from session not created: This version of ChromeDriver only supports Chrome version 114
问:
考虑:
import undetected_chromedriver as uc
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
import time
# Set up Chrome WebDriver
service = Service()
options = Options()
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--profile-directory=Default")
options.add_argument("--user-data-dir=C:\\Users\\athar\\AppData\\Local\\Google\\Chrome\\User Data\\")
driver = uc.Chrome(service = service, options = options)
driver.get("https://gmail.com/")
time.sleep(10)
# Close the browser
driver.quit()
我只是想在 Chrome 配置文件中打开 Gmail,这样我就不需要每次都登录,并且可以使用键盘快捷键激活扩展程序。运行上述脚本会给出 chromedriver 版本错误。如何使用正确版本的 chromedriver?我需要下载什么,我需要将什么驱动程序路径传递给 Web 驱动程序功能?
完全错误:
Traceback (most recent call last):
File "d:\programming\Python\Freelance\ExtensionAutomation\test.py", line 16, in <module>
driver = uc.Chrome(service = service, options = options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\athar\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 466, in __init__
super(Chrome, self).__init__(
File "C:\Users\athar\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__
super().__init__(
File "C:\Users\athar\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 56, in __init__
super().__init__(
File "C:\Users\athar\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 206, in __init__
self.start_session(capabilities)
File "C:\Users\athar\AppData\Local\Programs\Python\Python311\Lib\site-packages\undetected_chromedriver\__init__.py", line 724, in start_session
super(selenium.webdriver.chrome.webdriver.WebDriver, self).start_session(
File "C:\Users\athar\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 290, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\athar\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 345, in execute
self.error_handler.check_response(response)
File "C:\Users\athar\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:54613
from session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 116.0.5845.110
Stacktrace:
Backtrace:
GetHandleVerifier [0x00FDA813+48355]
(No symbol) [0x00F6C4B1]
(No symbol) [0x00E75358]
(No symbol) [0x00E961AC]
(No symbol) [0x00E906B4]
(No symbol) [0x00E90491]
(No symbol) [0x00EC0C55]
(No symbol) [0x00EC093C]
(No symbol) [0x00EBA536]
(No symbol) [0x00E982DC]
(No symbol) [0x00E993DD]
GetHandleVerifier [0x0123AABD+2539405]
GetHandleVerifier [0x0127A78F+2800735]
GetHandleVerifier [0x0127456C+2775612]
GetHandleVerifier [0x010651E0+616112]
(No symbol) [0x00F75F8C]
(No symbol) [0x00F72328]
(No symbol) [0x00F7240B]
(No symbol) [0x00F64FF7]
BaseThreadInitThunk [0x768D7D59+25]
RtlInitializeExceptionChain [0x77C6B79B+107]
RtlClearBits [0x77C6B71F+191]
答:
1赞
Estraviz
8/23/2023
#1
您的 Chrome 浏览器已更新到此方法当前不支持的新版本。您可以尝试在此网页上手动下载驱动程序(您应该根据您的 PC 和 Chrome 版本(在本例中为 117)获取 chrome 驱动程序):
https://googlechromelabs.github.io/chrome-for-testing/#stable
然后,您只需更改 Service 语句以瞄准该 Web 驱动程序,如下所示:
service=Service(executable_path=r"path_to_driver\chromedriver.exe")
评论
\
r"..."