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,这样我就不需要每次都登录了,而且可以使用键盘快捷键激活扩展.运行上述脚本时会出现chromeDRIVE版本错误.如何使用正确版本的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]