Python selenium.common.exceptions.WebDriverException

来源:互联网 发布:js字符串格式化0在前面 编辑:程序博客网 时间:2024/05/20 11:51

测试selenium报错

#!/usr/bin/python# coding=utf-8# author=Hefrom selenium import webdriverbrowser = webdriver.Chrome()browser.get("https://www.baidu.com")print(browser.title)browser.quit()

报错信息

/usr/bin/python3.5 /home/he/dev/python-test/run.pyTraceback (most recent call last):  File "/home/he/dev/python-test/run.py", line 7, in <module>    browser = webdriver.Chrome()  File "/usr/lib/python3/dist-packages/selenium/webdriver/chrome/webdriver.py", line 67, in __init__    desired_capabilities=desired_capabilities)  File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py", line 91, in __init__    self.start_session(desired_capabilities, browser_profile)  File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py", line 173, in start_session    'desiredCapabilities': desired_capabilities,  File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/webdriver.py", line 233, in execute    self.error_handler.check_response(response)  File "/usr/lib/python3/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response    raise exception_class(message, screen, stacktrace)selenium.common.exceptions.WebDriverException: Message: session not created exception: Chrome version must be >= 58.0.3029.0  (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 4.9.0-deepin4-amd64 x86_64)Process finished with exit code 1

浏览器驱动不存在或者驱动不适用当前版本
解决办法:
-chrome为例:
查看当前浏览器版本
输入chrome://help/
chromium版本

查看版本对应的驱动https://sites.google.com/a/chromium.org/chromedriver/downloads查看版本库https://chromedriver.storage.googleapis.com/index.html下载对应操作系统的文件

chromedriver库

copy到he@he-PC:/usr/lib/chromium$ sudo cp ~/Desktop/chromedriver ./

再次运行

/usr/bin/python3.5 /home/he/dev/python-test/run.py百度一下,你就知道Process finished with exit code 0
阅读全文
0 0
原创粉丝点击