selenium 无法在windows visual studio代码中使用chrome web_driver

mzsu5hc0  于 2022-12-18  发布在  Windows
关注(0)|答案(1)|浏览(131)

我试着运行这个代码

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))

误差如下所示

Output exceeds the size limit. Open the full output data in a text editor
-

WebDriverException                        Traceback (most recent call last)
Cell In \[4\], line 5
2 from selenium.webdriver.chrome.service import Service
3 from webdriver_manager.chrome import ChromeDriverManager
\----\> 5 driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
6 driver.get("https://www.google.com")

File c:\\Users\\varun\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\selenium\\webdriver\\chrome\\webdriver.py:81, in WebDriver.__init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, service, keep_alive)
78 if not service:
79     service = Service(executable_path, port, service_args, service_log_path)
\---\> 81 super().__init__(
82     DesiredCapabilities.CHROME\["browserName"\],
83     "goog",
84     port,
85     options,
86     service_args,
87     desired_capabilities,
88     service_log_path,
89     service,
90     keep_alive,
91 )

File c:\\Users\\varun\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\selenium\\webdriver\\chromium\\webdriver.py:106, in ChromiumDriver.__init__(self, browser_name, vendor_prefix, port, options, service_args, desired_capabilities, service_log_path, service, keep_alive)
103 self.service.start()
...
(No symbol) \[0x00A3051B\]
BaseThreadInitThunk \[0x753B7BA9+25\]
RtlInitializeExceptionChain \[0x76F9BB9B+107\]
RtlClearBits \[0x76F9BB1F+191\]

我已经安装了最新版本的 selenium 和我的内核是python 3.8.10 64位。我有勇敢的浏览器安装这是基于 chrome (版本1.46.134 chrome :108.0.5359.94(官方版本)(64位)),但我仍然无法运行此代码。请帮助

v1uwarro

v1uwarro1#

尝试更新驱动程序:

from webdriver_manager.core.utils import ChromeType

driver = webdriver.Chrome(service=Service(ChromeDriverManager(chrome_type=ChromeType.BRAVE).install()))

相关问题