selenium webdriver chrome 115停止工作

k5hmc34c  于 2023-07-31  发布在  Go
关注(0)|答案(9)|浏览(293)

我在Windows上安装了Chrome 115.0.5790.99,并且我使用的是Selenium 4.10.0。在我的python代码中,我调用service = Service(ChromeDriverManager().install()),它返回错误**ValueError:没有这样的驱动程序由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 115将最终在这里发布https://chromedriver.chromium.org/downloads

tuwxkamq

tuwxkamq1#

Selenium Manager现在完全包含在selenium4.10.0中,所以这就是您所需要的:

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

service = Service()
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)
# ...
driver.quit()

字符串
如果在您的系统PATH中找不到驱动程序,Selenium Manager将自动下载它。
如果你想知道为什么你现在看到这个错误的ChromeDriverManager,这是因为https://chromedriver.chromium.org/downloads只升级到版本114由于驱动程序重组的 chrome 团队为新的Chrome-for-Testing

vjhs03f7

vjhs03f72#

对我来说是工作
service = Service(ChromeDriverManager(version=“114.0.5735.90”).install())

fdbelqdn

fdbelqdn3#

不确定你使用的是哪个版本的selenium,如果你使用的是最新版本的selenium v4.6.0或更高版本,你不必使用第三方库(如WebDriverManager)来处理浏览器驱动程序。你的代码可以简化如下:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://www.crawler-test.com")
print(driver.title)

字符串
结果:

Crawler Test Site

Process finished with exit code 0

更新:ChromeWebDriverManager与确保WebDriver的稳定版本无关,它用于确保根据系统中的浏览器版本使用正确版本的驱动程序二进制文件(chormedriver.exe)。话虽如此,现在使用selenium v4.6.0或更高版本,selenium的内置工具SeleniumManager将为我们处理浏览器驱动程序。换句话说,SeleniumManager将执行WebDriverManager以前执行的操作。
参考:Introducing Selenium Manager

6za6bjd0

6za6bjd04#

试试这个:service = Service(ChromeDriverManager(version=“114.0.5735.90”).install())

zaq34kh6

zaq34kh65#

在稳定的webdriver版本115发布之前,解决方案是使用测试webdriver并相应地测试Chrome。步骤如下:

  • 从系统中卸载当前安装的webdriver和Chrome;
  • 在这里找到稳定版本的webdriver和Chrome https://googlechromelabs.github.io/chrome-for-testing/
  • 搜索二进制chrome和chromedriver(webdriver和Chrome的版本应该是一样的!);
  • 安装Chrome(实际上你只是解压缩它,并把它放在一些文件夹,即:c:\chrome-test-ver);
  • 设置文件夹c:\chrome-test-ver为PATH环境变量);
  • 安装webdriver.exe(只需解压并复制到Python文件夹,即:C:\Users\Administrator\AppData\Local\Programs\Python\Python311);
  • 用selenium运行你的python脚本,它应该可以工作。
jxct1oxe

jxct1oxe6#

从Chrome v115开始,您需要安装“Google Chrome for Testing”https://developer.chrome.com/blog/chrome-for-testing才能在Chrome上本地运行任何自动测试。

trnvg8h3

trnvg8h37#

我已经更新了webdriver-manager,之后没有遇到任何问题。
pip install --upgrade webdriver-manager

vfwfrxfs

vfwfrxfs8#

我有这段代码,有人能帮我转换成新的115语法吗?

from webdriver_manager.chrome import ChromeDriverManager

 from selenium import webdriver
 from selenium.webdriver.common.by import By
 from selenium.webdriver.common.action_chains import ActionChains
 from selenium.webdriver.support import expected_conditions
 from selenium.webdriver.support.wait import WebDriverWait
 from selenium.webdriver.common.keys import Keys
 from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

    self.driver = webdriver.Chrome(ChromeDriverManager().install())
    self.vars = {}
    self.driver.get("https://www.google.com")

字符串

f0brbegy

f0brbegy9#

对于那些在2023年7月26日之后在使用selenium 4.8.0的测试应用程序中遇到问题的人来说,实际上在2023年7月26日chrome自动更新到版本115.0.5790.110,其Web驱动程序尚未上传到任何地方,最可靠的网站https://googlechromelabs.github.io/chrome-for-testing/#stable和https://chromedriver.chromium.org/downloads,但没有任何Web驱动程序可用。
好消息是,我找到了解决方案,我的代码工作得很好,我的测试工具也像旧的一样工作得很好。这是您的密码。在运行这些代码之前,需要执行以下步骤:
Step - 01. pip uninstall selenium Step - 02. pip install selenium==4.10.0 Step - 03. pip show selenium(确保安装了selenium版本4.10.0)。Step - 04. pip install webdriver_manager

Python/selenium 4.10.0代码

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

options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), 
options=options)

url = 'https://www.google.com/'
driver.get(url)
driver.maximize_window()
sleep(10)

字符串
如果有人想停止Chrome的自动更新,请随时问我,我也可以给予你同样的解决方案。

相关问题