小编Pol*_*tti的帖子

selenium.common.exceptions.NoSuchDriverException:消息:使用 Selenium 和 ChromeDriver 时无法使用 Selenium Manager 获取 chromedriver 错误

我不明白为什么我的代码总是出错

这是我的代码:

from selenium import webdriver

url = "https://google.com/"
path = "C:/Users/thefo/OneDrive/Desktop/summer 2023/chromedriver_win32"

driver = webdriver.Chrome(path)
driver.get(url)
Run Code Online (Sandbox Code Playgroud)

chromedriver的路径:

来自 chromedriver 的路径

这是总是出现的错误:

Traceback (most recent call last):
  File "C:\Users\thefo\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 42, in get_path
    path = SeleniumManager().driver_location(options) if path is None else path
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\thefo\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 74, in driver_location
    browser = options.capabilities["browserName"]
              ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'capabilities'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\thefo\OneDrive\Desktop\summer 2023\Projeto Bot Discord - BUFF SELL CHECKER\teste2.py", …
Run Code Online (Sandbox Code Playgroud)

python selenium-chromedriver selenium-webdriver seleniummanager

5
推荐指数
1
解决办法
2万
查看次数