自动化测试、动态内容爬取、模拟打开浏览器工具selenium 的安装使用(chrome 116 , 117, 118, 119 更新的版本)

selentium 要和chrome版本一致,找了很久119版本chrome的selentium,终于找到并测试通过可以使用,更新的版本也有

1、下载chrome for testing ,这个很适合用来做自动化测试和爬虫,因为不会自动升级

https://googlechromelabs.github.io/chrome-for-testing/

我下载的是当前最新版本119版本

2、下载对应版本的chromedriver

我上面下载了119版本的,所以,chromedriver也是下载119版本的

并把它放到第一步chrome for testing 的目录下

3、设置环境变量

在“系统环境变量”编辑“path”并增加 chrome for testing的目录

4、测试

用以下python 代码测试

from selenium import webdriver
browser = webdriver.Chrome()
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--ignore-certificate-errors')
browser.get("https://www.baidu.com")
print(browser.title)
browser.close()

 会自动启动chrome for test 并打印网页title

 

posted @ 2023-11-22 08:39  i金少  阅读(392)  评论(0编辑  收藏  举报