Selenium报错-selenium.common.exceptions.SessionNotCreatedException

219 阅读1分钟

报错信息

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())

重新运行,即可解决。