Selenium报错-selenium.common.exceptions.SessionNotCreatedException

报错信息

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 89
Current browser version is 92.0.4515.159 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

在使用Selenium的过程中,经常会遇到浏览器版本号的报错,一般网上的解决方案有两种:

1.去Google官网下载Chrome浏览器的最新版本驱动,安装即可解决问题

2.禁掉Google浏览器的自动更新

但其实还有一种更方便的解决方案,可以通过webdriver-manager来解决

解决办法

导入头文件
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

使用
self.driver = webdriver.Chrome(ChromeDriverManager().install())

重新运行,即可解决。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容