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

相关推荐
依旧很淡定2 天前
Selenium(Python)创建Chrome浏览器实例
chrome·python·selenium
加油20193 天前
爬虫框架: selenium API使用介绍
爬虫·selenium·测试工具
shelter -唯3 天前
基于selenium库的爬虫实战:京东手机数据爬取
爬虫·python·selenium
深蓝电商API7 天前
实战破解前端渲染:当 Requests 无法获取数据时(Selenium/Playwright 入门)
前端·python·selenium·playwright
卓码软件测评7 天前
第三方软件验收测试:【AutoIt与Selenium结合测试文件上传/下载等Windows对话框】
windows·功能测试·selenium·测试工具·性能优化·可用性测试
最好的我们!7 天前
解决selenium的EdgeOptions addArguments is not supported问题
selenium·测试工具
万粉变现经纪人8 天前
如何解决 pip install 安装报错 ImportError: cannot import name ‘xxx’ from ‘yyy’ 问题
python·selenium·测试工具·flask·scikit-learn·fastapi·pip
gc_22998 天前
学习Python中Selenium模块的基本用法(18:使用ActionChains操作鼠标)
python·selenium
paid槮9 天前
selenium完整版一览
selenium·测试工具
gc_22999 天前
学习Python中Selenium模块的基本用法(17:使用ActionChains操作键盘)
python·selenium