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

重新運行,即可解決。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章