运行.py提示selenium.common.exceptions.WebDriverException

今天打开上次运行成功的.py文件,发现报错,报错信息如下:in/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/zhangyanyan/PycharmProjects/untitled1/baidu.py

Traceback (most recent call last):

  File "/Users/zhangyanyan/PycharmProjects/untitled1/baidu.py", line 3, in

    driver = webdriver.Firefox()

  File "/Library/Python/2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 81, in __init__

    self.binary, timeout)

  File "/Library/Python/2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 51, in __init__

    self.binary.launch_browser(self.profile, timeout=timeout)

  File "/Library/Python/2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser

    self._wait_until_connectable(timeout=timeout)

  File "/Library/Python/2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 98, in _wait_until_connectable

    raise WebDriverException("The browser appears to have exited "

selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

Process finished with exit code 1

百度了一下,猜测应该是本机的fi​refox安装后未设置为非自动更新,导致firefox自动更新到最新版本,而selenium最新版并不支持firefox的最新版。

解决方法:

方法一:降firefox版本;

方法二:升selenium 的jar包;​

方法三:下载与该版本selenium匹配的其他浏览器的驱动;

方法四:修改selenium兼容firefox版本的配置文件:

http://bbs.51testing.com/thread-1075662-1-1.html

转载于:https://www.cnblogs.com/ming1220/p/8320753.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值