解决:selenium web browser 的版本适配问题

这篇具有很好参考价值的文章主要介绍了解决:selenium web browser 的版本适配问题。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

  • 使用 selenium 操控浏览器的时候报错:
The chromedriver version (114.0.5735.90) detected in PATH at /opt/homebrew/bin/chromedriver might not be compatible with the detected chrome version (122.0.6261.69); currently, chromedriver 122.0.6261.69 is recommended for chrome 122.*, so it is advised to delete the driver in PATH and retry
Traceback (most recent call last):
  File "/Users/qinpeinuan/Desktop/NUS/2024 sem1/CS5342 Multi-media computing/recommendation_system/perception_evaluation/TemplateFill.py", line 11, in <module>
    driver = webdriver.Chrome()
  File "/Users/qinpeinuan/opt/anaconda3/envs/rs/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/Users/qinpeinuan/opt/anaconda3/envs/rs/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 61, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/Users/qinpeinuan/opt/anaconda3/envs/rs/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 208, in __init__
    self.start_session(capabilities)
  File "/Users/qinpeinuan/opt/anaconda3/envs/rs/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 292, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "/Users/qinpeinuan/opt/anaconda3/envs/rs/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute
    self.error_handler.check_response(response)
  File "/Users/qinpeinuan/opt/anaconda3/envs/rs/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 122.0.6261.69 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Stacktrace:
0   chromedriver                        0x0000000102e5bf48 chromedriver + 4226888
1   chromedriver                        0x0000000102e544f4 chromedriver + 4195572
2   chromedriver                        0x0000000102a98d68 chromedriver + 281960
3   chromedriver                        0x0000000102ac4bac chromedriver + 461740
4   chromedriver                        0x0000000102ac0fd8 chromedriver + 446424
5   chromedriver                        0x0000000102abe150 chromedriver + 434512
6   chromedriver                        0x0000000102afb93c chromedriver + 686396
7   chromedriver                        0x0000000102afb164 chromedriver + 684388
8   chromedriver                        0x0000000102ac7f1c chromedriver + 474908
9   chromedriver                        0x0000000102ac8ef4 chromedriver + 478964
10  chromedriver                        0x0000000102e1d59c chromedriver + 3970460
11  chromedriver                        0x0000000102e216f0 chromedriver + 3987184
12  chromedriver                        0x0000000102e275b4 chromedriver + 4011444
13  chromedriver                        0x0000000102e222fc chromedriver + 3990268
14  chromedriver                        0x0000000102dfa1c0 chromedriver + 3826112
15  chromedriver                        0x0000000102e3e088 chromedriver + 4104328
16  chromedriver                        0x0000000102e3e1e0 chromedriver + 4104672
17  chromedriver                        0x0000000102e4df28 chromedriver + 4169512
18  libsystem_pthread.dylib             0x0000000187e01034 _pthread_start + 136
19  libsystem_pthread.dylib             0x0000000187dfbe3c thread_start + 8


解决方案:使用 webdriver manager 自动适配驱动

  • 参考原链接
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

option = webdriver.ChromeOptions()
option.add_argument("start-maximized")


driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=option)
driver.get('https://www.google.com/')

文章来源地址https://www.toymoban.com/news/detail-839310.html

到了这里,关于解决:selenium web browser 的版本适配问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包