Python selenium.common.exceptions.WebDriverException

测试selenium报错

#!/usr/bin/python
# coding=utf-8
# author=He

from selenium import webdriver

browser = webdriver.Chrome()

browser.get("https://www.baidu.com")
print(browser.title)
browser.quit()

报错信息

/usr/bin/python3.5 /home/he/dev/python-test/run.py
Traceback (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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值