在试图与Selenium Webdriver制造一个物体时,我犯了以下错误。
"seleniumwebdrivercommondriver_finder.py", line 42, in get_path
path = SeleniumManager().driver_location(options) if path is None else path
"seleniumwebdrivercommonselenium_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):
"selenium_webdriver_webscraping.py", line 4, in <module>
driver = webdriver.Chrome(chrome_driver_path)
"seleniumwebdriverchromewebdriver.py", line 47, in __init__
self.service.path = DriverFinder.get_path(self.service, self.options)
"seleniumwebdrivercommondriver_finder.py", line 44, in get_path
raise NoSuchDriverException(f"Unable to obtain {service.path} using Selenium Manager; {err}")
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain chromedriver using Selenium Manager; str object has no attribute capabilities ; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
This is the code I used:
from selenium import webdriver
chrome_driver_path = <chrome drive .exe path>
driver = webdriver.Chrome(chrome_driver_path)