惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
C
CERT Recently Published Vulnerability Notes
P
Proofpoint News Feed
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
云风的 BLOG
云风的 BLOG
H
Help Net Security
Recorded Future
Recorded Future
The Register - Security
The Register - Security
F
Full Disclosure
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
Security Archives - TechRepublic
Security Archives - TechRepublic
Simon Willison's Weblog
Simon Willison's Weblog
Cisco Talos Blog
Cisco Talos Blog
I
InfoQ
T
Tenable Blog
T
Tor Project blog
人人都是产品经理
人人都是产品经理
D
DataBreaches.Net
NISL@THU
NISL@THU
Google DeepMind News
Google DeepMind News
博客园 - 叶小钗
B
Blog
V
V2EX
Jina AI
Jina AI
L
LangChain Blog
月光博客
月光博客
W
WeLiveSecurity
U
Unit 42
AWS News Blog
AWS News Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
博客园 - 聂微东
V
Visual Studio Blog
A
Arctic Wolf
T
Tailwind CSS Blog
The Cloudflare Blog
SecWiki News
SecWiki News
S
SegmentFault 最新的问题
Hacker News - Newest:
Hacker News - Newest: "LLM"
宝玉的分享
宝玉的分享
MyScale Blog
MyScale Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Securelist
www.infosecurity-magazine.com
www.infosecurity-magazine.com
腾讯CDC
雷峰网
雷峰网

阿猪的博客

如何使用CNB构建Hexo项目并部署到腾讯云COS 好坑爹!派息后买入的股票怎么也扣股息税? 游哈尔滨 跨年往事 安装Ta-Lib时报错"Could not build wheels" 网站被恶意镜像了该怎么办 延迟退休正式到来!来看看有什么规定 我的基金怎么就被强制卖出了? Hexo-AlgoliaSearch插件报错“Error has occurred during indexing posts” 找工作避坑不完全指南 办理信用卡应该注意什么 华为Pad开启了“共享至电脑”,但是Windows下无法正常访问 webdriver-manager报错一例 Windows无法从环境变量中找到Python的正确位置 习大大2024年新年贺词 号外!号外!Twikoo可以直接屏蔽垃圾评论啦! 如何将Coding的代码仓同步到Github 博客被攻击了 华为Pad开启了“共享至电脑”,但是Ubuntu下无法正常访问 如何恢复Etcher刻录过的U盘 如何在Ubuntu下快速切换网络代理状态 在腾讯云函数中使用Pandas报错`No module named 'numpy.core._multiarray_umath'` 对空的DataFrame使用apply方法未得到预期结果 SQLite中使用关键字作为列名称导致报错 Logging模块重复输出内容的原因及解决方法 如何在Selenium中保持网站的登录状态 如何下载旧版本Python的安装包 如何为不同的Python项目自动选择不同的解释器 使用腾讯云函数搭建Web站点 WordPress CORS问题一例 踩坑阿里云函数计算搭建WordPress 在AWS Amplify中部署Jekyll站点 让Chirpy主题支持折叠展示代码块 实现ChatGPT的文字输出效果 python中使用'''注释代码后引起报错 使用python自带的email模块解析邮件 使用pandas_bokeh在地图上显示数据 如何通过复权因子计算复权价格 国内量化平台不完全汇总
如何下载与Chrome浏览器的版本相匹配的ChromeDriver
阿猪 · 2023-08-22 · via 阿猪的博客

  本文介绍下载与Chrome浏览器的版本相匹配的ChromeDriver的两种方法。

一、问题场景

  Selenium是一个广泛使用的Web自动化测试工具,配合ChromeDriver使用,可以通过Python控制Chrome浏览器模拟各种用户操作。阿猪之前使用一直都正常,但是今天在运行时却出现如下报错信息:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 114
Current browser version is 116.0.5845.97 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe

  根据报错信息,是Chrome浏览器的版本超过了ChromeDriver支持的版本,可能是Chrome浏览器自动升级后导致的。要解决这个问题,可以手工下载对应版本的ChromeDriver,或者使用webdriver-manager自动管理ChromeDriver的版本。

二、手工下载对应版本的ChromeDriver

1、打开ChromeDriver的下载页面,下载与Chrome浏览器对应的版本。
  对于114及以下的版本,可以在这个页面下载,对于115及以上的版本,可以在Chrome for Testing availability页面下载

2、在python代码中指定ChromeDriver的路径。
  以Window为例,示例代码如下:

1
2
3
from selenium import webdriver

obj_page = webdriver.Chrome(executable_path='<chromedriver文件的路径>')

如果是Linux环境,需要确保ChromeDriver文件具有执行权限,否则可能会遇到如下报错:

Traceback (most recent call last):
File “/home/zhu/Documents/liepin/main.py”, line 499, in
obj_page = webdriver.Chrome(service=chrome_service, options=obj_option)
File “/home/zhu/zhu-env/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py”, line 45, in init
super().init(
File “/home/zhu/zhu-env/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py”, line 50, in init
self.service.start()
File “/home/zhu/zhu-env/lib/python3.10/site-packages/selenium/webdriver/common/service.py”, line 98, in start
self._start_process(self._path)
File “/home/zhu/zhu-env/lib/python3.10/site-packages/selenium/webdriver/common/service.py”, line 230, in _start_process
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver-linux64-122.0.6261.128’ executable may have wrong permissions.

需要在终端中使用以下命令为文件添加执行权限:

1
chmod +x <chromedriver文件的路径>

三、使用webdriver-manager自动管理ChromeDriver的版本

1、安装webdriver

1
pip install webdriver-manager

2、在python中引用webdriver-manager
  以Window为例,示例代码如下:

1
2
3
4
5
6
7
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager

str_driver_path = ChromeDriverManager().install()
chrome_service = ChromeService(str_driver_path)
obj_page = webdriver.Chrome(service=chrome_service)

版权声明: 未经书面授权许可,任何个人和组织不得以任何形式转载、引用本站的任何内容。本站保留追究侵权者法律责任的权利。

赏杯咖啡,鼓励一下~

  • 微信打赏

    微信打赏