我在Windows上安装了Chrome 115.0.5790.99,并使用Selenium 4.10.0。在我的Python代码中,我调用了service = Service(ChromeDriverManager().install()),但返回了错误ValueError: There is no such driver by url https://chromedriver.storage.googleapis.com/LATEST_RELEASE_115.0.5790.。我使用ChromeDriverManager().install()来确保使用最新稳定版本的webdriver。如何解决这个问题?
我的简单代码:
错误输出:
我尝试了以下方法,但都没有成功:
我的简单代码:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import time
# Install Webdriver
service = Service(ChromeDriverManager().install())
# Create Driver Instance
driver = webdriver.Chrome(service=service)
# Get Web Page
driver.get('https://www.crawler-test.com')
time.sleep(5)
driver.quit()
错误输出:
Traceback (most recent call last):
File "C:\Users\Administrator\Documents\...\test.py", line 7, in <module>
service = Service(ChromeDriverManager().install())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\webdriver_manager\chrome.py", line 39, in install
driver_path = self._get_driver_path(self.driver)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\webdriver_manager\core\manager.py", line 30, in _get_driver_path
file = self._download_manager.download_file(driver.get_driver_download_url())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\webdriver_manager\drivers\chrome.py", line 40, in get_driver_download_url
driver_version_to_download = self.get_driver_version_to_download()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\webdriver_manager\core\driver.py", line 51, in get_driver_version_to_download
self._driver_to_download_version = self._version if self._version not in (None, "latest") else self.get_latest_release_version()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\webdriver_manager\drivers\chrome.py", line 62, in get_latest_release_version
resp = self._http_client.get(url=latest_release_url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\webdriver_manager\core\http.py", line 37, in get
self.validate_response(resp)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\webdriver_manager\core\http.py", line 16, in validate_response
raise ValueError(f"There is no such driver by url {resp.url}")
ValueError: There is no such driver by url https://chromedriver.storage.googleapis.com/LATEST_RELEASE_115.0.5790
我尝试了以下方法,但都没有成功:
- 禁用Chrome自动更新,但Chrome仍然能够自动更新(https://www.minitool.com/news/disable-automatic-chrome-updates.html和https://www.webnots.com/7-ways-to-disable-automatic-chrome-update-in-windows-and-mac);
- 安装Chrome 114和webdriver版本114,它可以正常工作,直到Chrome自动更新;
- 按照https://chromedriver.chromium.org/downloads/version-selection的说明操作,但在生成URL并运行链接https://chromedriver.storage.googleapis.com/LATEST_RELEASE_115.0.5790时,出现错误No such object: chromedriver/LATEST_RELEASE_115.0.5790