运行.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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM