chromedriver安装和环境变量配置

chromedriver

1、安装

网上随便搜一篇chromedriver的安装文档即可。这里是一个快速链接
特别提醒:截止2024.1.30,chromedriver.exe已经更新到121.xx了,如果你在官网上没有找到和你google chrome版本一致的chromedriver.exe,建议先把本地的google chrome升级到最新版本,再去下载对应版本的chromedriver.exe。

2、【重点】环境变量配置

对解压包里的chromedrive.exe进行如下操作:

(1)包的复制:
  • 复制1 :复制任意一个需要管理员就可以访问的文件夹下!
    • 默认google 的安装目录在"C:\Program Files\Google\Chrome\Application",但C:\Program Files需要管理员权限,如果把chromedriver.exe放在该目录下,可能无法正常访问。我的最终路径:"D:\othersoft\google":
  • 复制2 :检查引用from selenium import webdriver的.py脚本所使用的python环境,把chromedrive.exe在当前python环境下也复制一份。
    • 比如.py使用的环境安装在"D\python3.10\xx", 则直接把chromedrive.exe复制到"D\python3.10"目录下即可。
(2)系统环境变量配置

复制1中chromedriver.exe的路径添加到系统环境PATH中。

3、验证

(1)第一种

复制代码
chromedriver --version

(2)第二种

复制代码
from selenium import webdriver
driver = webdriver.Chrome()

会启动一个chrome窗口,并马上关闭。

相关推荐
不会代码的小测试3 小时前
UI自动化-针对验证码登录的系统,通过首次手动登录存储cookie的方式后续访问免登录方法
开发语言·python·selenium
0思必得05 小时前
[Web自动化] 数据抓取、解析与存储
运维·前端·爬虫·selenium·自动化·web自动化
0思必得018 小时前
[Web自动化] 爬虫之API请求
前端·爬虫·python·selenium·自动化
0思必得020 小时前
[Web自动化] 爬虫之网络请求
前端·爬虫·python·selenium·自动化·web自动化
深蓝电商API1 天前
Selenium 与 BeautifulSoup 结合解析页面
爬虫·python·selenium·beautifulsoup
深蓝电商API1 天前
Selenium 绕过 Cloudflare 反爬检测
爬虫·python·selenium
0思必得01 天前
[Web自动化] 爬虫实例(获取时光网某个年度电影数据)
前端·爬虫·python·selenium·自动化
@zulnger1 天前
selenium 自动化测试工具实战项目(客户)
selenium·测试工具·自动化
0思必得01 天前
[Web自动化] 爬虫基础
运维·爬虫·python·selenium·自动化·html
Jul1en_1 天前
【Web自动化测试】Selenium常用函数+IDEA断言配置
前端·selenium·intellij-idea