我正在使用selenium和python,并从我的网站下载了我的Windows计算机的chromedriver:http://chromedriver.storage.googleapis.com/index.html?path = 2.15 /
下载zip文件后,我将zip文件解压缩到我的下载文件夹.然后我将路径到可执行二进制文件(C:\ Users\michael\Downloads\chromedriver_win32)放入环境变量"路径".
但是,当我运行以下代码时:
from selenium import webdriver
driver = webdriver.Chrome()
Run Code Online (Sandbox Code Playgroud)
...我一直收到以下错误消息:
WebDriverException: Message: 'chromedriver' executable needs to be available in the path. Please look at http://docs.seleniumhq.org/download/#thirdPartyDrivers and read up at http://code.google.com/p/selenium/wiki/ChromeDriver
Run Code Online (Sandbox Code Playgroud)
但是 - 如上所述 - 可执行文件是(!)在路径中...这里发生了什么?
#Once the zip has finished downloading, extract the folder and copy the path of the chromedriver exe file (should be the #first one), add it to your code like this,
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
url = "somewebsite.com"
service_obj = Service("D:\\Users\\eggman\Downloads\chromedriver-win64\chromedriver-win64\chromedriver.exe")
driver = webdriver.Chrome(service=service_obj)
driver.get(url)
Run Code Online (Sandbox Code Playgroud)
返回错误:
selenium.common.exceptions.SessionNotCreatedException:此版本的 ChromeDriver 仅支持 Chrome 版本 114。LATEST_RELEASE_115 不存在
我想为了避免这种情况,我可以关闭自动更新吗?
我最初使用了以下代码,效果很好
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
Run Code Online (Sandbox Code Playgroud) 尝试使用 Selenium Webdriver 创建对象时出现以下错误。
"\selenium\webdriver\common\driver_finder.py", line 42, in get_path
path = SeleniumManager().driver_location(options) if path is None else path
"\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):
"\selenium_webdriver_webscraping.py", line 4, in <module>
driver = webdriver.Chrome(chrome_driver_path)
"\selenium\webdriver\chrome\webdriver.py", line 47, in __init__
self.service.path = DriverFinder.get_path(self.service, self.options)
"\selenium\webdriver\common\driver_finder.py", line 44, in get_path
raise NoSuchDriverException(f"Unable to obtain {service.path} using Selenium Manager; {err}")
selenium.common.exceptions.NoSuchDriverException: Message: …Run Code Online (Sandbox Code Playgroud)