解決Chrome與chromedriver版本不一致的問題


今天使用selenium時遇到如下異常信息:

driver.get('https://www.baidu.com')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\python3.7.3-install-path\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "D:\python3.7.3-install-path\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "D:\python3.7.3-install-path\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"1902135EC45F5C7A8A0CD69740B466CA","isDefault":true,"type":"default"},"id":1,"name":"","origin":"://"}
(Session info: chrome=70.0.3538.102)
(Driver info: chromedriver=2.6.233026,platform=Windows NT 6.3 x86_64)

 

其原因就是Chrome與chromedriver版本不一致,解決方案:

異常信息中指出我chrome的版本是70.0.3538.102,而chromedriver版本是2.6.233026,明顯版本不對應:

所以就需要去以下網址下載對應版本的chromedriver:

 http://npm.taobao.org/mirrors/chromedriver/

找到對應版本的chromedriver下載並放在對應python版本的Scripts文件夾下:

 

 

然后就可以正常驅動打開網頁了:

 

如有錯誤,歡迎指正!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM