提问人:eggman 提问时间:8/16/2023 最后编辑:eggman 更新时间:10/23/2023 访问量:54721
selenium.common.exceptions.SessionNotCreatedException:此版本的 ChromeDriver 仅支持 Chrome 版本 114。LATEST_RELEASE_115不存在
selenium.common.exceptions.SessionNotCreatedException: This version of ChromeDriver only supports Chrome version 114. LATEST_RELEASE_115 doesn't exist
问:
访问以下链接并下载相应版本
#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)
返回错误:
selenium.common.exceptions.SessionNotCreatedException:此版本的 ChromeDriver 仅支持 Chrome 版本 114。LATEST_RELEASE_115不存在
我猜为了避免将来出现这种情况,我可以关闭自动更新吗?
我最初使用了以下代码,效果很好
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
答:
对于 Chrome/chromedriver 116+,解决方案类似于 https://stackoverflow.com/a/76731553/7058266,但现在您需要 .然后在运行时获取正确的驱动程序。selenium
4.11.2
selenium
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
service = Service()
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)
# ... Automate something here
driver.quit()
有关新的 Chrome-for Testing 的详细信息,请参阅 https://googlechromelabs.github.io/chrome-for-testing/(这也包括用于测试的 chromedrivers)。
评论
~/.cache/selenium
brew
对于我的设置,这个问题的解决方案非常简单(虽然是在大量研究后才发现的),这要归功于这个 https://www.youtube.com/watch?v=OlMX0gxyL58。
即使我使用的是最新的 selenium (4.11.2),我仍然收到有关版本不匹配的错误。
我从 Chrome 114 下载 https://googlechromelabs.github.io/chrome-for-testing/ 解压缩到我的下载文件夹中,然后添加此代码以设置二进制位置
options.binary_location = r"ADD_YOUR_PATH\chrome.exe"
评论
请使用以下命令升级 selenium。它帮助我解决了这个问题,这个版本的selenium将开始识别正确的浏览器版本。(环境:windows10、pycharm、venv)
pip install -U selenium==4.11.2
安装 selenium v4.11.2 后,一切正常,我遇到了 v4.10 的问题
对于未检测到的 chromedriver 用户:从开始帖子中的链接获取最新版本的驱动程序,然后使用driver_executable_path参数。此外,您还需要更新 selenium 和 undetected_chromedriver 库。
driver = uc.Chrome(driver_executable_path=r"chromedriver-win64\chromedriver.exe", options=options)
其中文件夹 chromedriver-win64 在脚本的目录中。如果您不编写此参数,程序将尝试自动获取不支持 Chrome 115+ 的版本
将 OP 的解决方案从问题迁移到答案:
我找到了一个解决方案(在 python 中)并想分享, 转到 Chrome Labs 测试页面,复制您平台的相应“URL”并将其粘贴到您的浏览器中,下载将开始。我根据我的 chrome 浏览器自动更新到的版本选择了版本,该版本是 116.0.5845.97。您可以通过在 chrome 浏览器中打开设置,然后单击“关于 Chrome”来找到它。
对我来说,使用 python selenium,当 Chrome 从 115 更新到 116 时它停止工作,我下载了 chrome 驱动程序 116,但仍然出现相同的错误。我尝试从 4.9.0 更新 selenium,但进一步遇到了不同的错误,所以恢复了。最后,解决方案是将文件放在驱动程序路径中,而不仅仅是目录。我从这里改变了:
python -m pytest --driver Chrome --driver-path c:\Users\MyName\code\chromedriver-win64-116\
对此:
python -m pytest --driver Chrome --driver-path c:\Users\MyName\code\chromedriver-win64-116\chromedriver.exe
为了解决这个问题,我只是将 Chrome 更新到版本 117,然后更改了我使用的 cromedriver 以匹配版本,我在这里找到了它(我从 chromedriver 官方下载页面找到了列表)。我用来启动 cromedriver 的代码是:
from pathlib import Path
from selenium.webdriver.chrome.service import Service as ChromeService
service = ChromeService(executable_path=Path.cwd() / 'chromedriver_mac64')
(当然,我将 chromedriver 可执行文件重命名为 )。
希望它能帮助处于相同情况的任何人。chromedriver_mac64
遇到同样的问题,我尝试了以下方法,它奏效了。
pip install chromedriver-py
安装完成后使用以下代码
from selenium import webdriver
from chromedriver_py import binary_path # this will get you the path variable
svc = webdriver.ChromeService(executable_path=binary_path)
driver = webdriver.Chrome(service=svc)
# deprecated but works in older selenium versions
# driver = webdriver.Chrome(executable_path=binary_path)
driver.get("http://www.python.org") #
assert "Python" in driver.title
只需降级到 Chrome 版本 114:
apt-get update
wget http://dl.google.com/linux/deb/pool/main/g/google-chrome-unstable/google-chrome-unstable_114.0.5735.6-1_amd64.deb
sudo apt-get install -f ./google-chrome-unstable_114.0.5735.6-1_amd64.deb
sudo ln -s /opt/google/chrome-unstable/google-chrome google-chrome-stable
114.0.5735.6-1 是 Chrome 版本 114 的最后一个版本
评论