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