解决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