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窗口,并马上关闭。

相关推荐
只看不学1 天前
selenium自动下载更新浏览器对应的webdriver
selenium·测试工具
BatyTao1 天前
Selenium自动化测试快速入门指南
python·selenium·测试工具
晨曦5432102 天前
Selenium Grid
selenium·测试工具
郭天宇 abfore6 天前
Selenium
selenium·测试工具·web自动化测试
Python大数据分析@8 天前
selenium采集数据怎么应对反爬机制?
selenium·测试工具·网络爬虫
测试199810 天前
Web自动化测试:测试用例流程设计
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
程序员三藏12 天前
Selenium+python自动化测试:解决无法启动IE浏览器及报错问题
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例
Warren9812 天前
软件测试-Selenium学习笔记
java·javascript·笔记·学习·selenium·测试工具·安全
中草药z14 天前
【自动化测试】Selenium详解-WebUI自动化测试
前端·功能测试·selenium·自动化·html·web·测试
gc_229915 天前
使用HtmlAgilityPack+PuppeteerSharp+iText7抓取Selenium帮助文档
selenium·itext7·htmlagilitypack·puppeteersharp