chromedriver 116 版本下载
- 老版本下载(<=114): https://chromedriver.chromium.org/downloads
- 新版本下载: https://googlechromelabs.github.io/chrome-for-testing/
- 具体步骤可参考文章: Chrome116驱动下载路径 解决版本不匹配问题
新版本下载后是Google Chrome for Testing.app
, 官网介绍Chrome for Testing: reliable downloads for browser automation
chromedriver 环境变量配置
我下载的版本是: 116 mac-arm64
- 下载后
chrome-mac-arm64.zip
解压为:/chrome-mac-arm64/Google Chrome for Testing.app
- 在
/usr/local
下新建文件夹chromedriver
- 移动文件
Google Chrome for Testing.app
到/usr/local/chromedriver
- 懒得空格转义,就把
Google Chrome for Testing.app
改名为chromedriver.app
, 所以得到/usr/local/chromedriver/chromedriver.app
/usr/local/chromedriver/chromedriver.app/Contents/MacOS/Google Chrome for Testing.app
也改名为
chromedriver.app
, , 所以得到/usr/local/chromedriver/chromedriver.app/Contents/MacOS/chromedriver
1 | from selenium import webdriver |
这时候执行,chromedriver可以启动chrome窗口,但是无法打开页面’https://www.baidu.com’, 然后报错:
1 | driver = webdriver.Chrome(executable_path=driver_path) |
踩坑
“Google Chrome for Testing.app” is damaged and can’t be opened. You should move it to the Trash."
提示程序含有恶意代码或者已经打开所有来源还是提示扔到垃圾桶
Google Chrome for Testing.app官方解决方法: https://github.com/GoogleChromeLabs/chrome-for-testing#macos-says-the-app-is-damaged-what-now
在终端输入 sudo xattr -cr 'Google Chrome for Testing.app'