0

我試圖寫測試用例使用Selenium我的web應用程序,Firefox和蟒蛇webdrivers,而我的開發環境是在Ubuntu 16.04 LTS的設置,但我得到異常,硒不與Firefox和ububtu蟒蛇webdriver的工作

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. 

這裏是我的代碼塊

from selenium import webdriver 
from selenium.webdriver.common.keys import Keys 

driver = webdriver.Firefox() 
driver.get("http://www.python.org") 
assert "Python" in driver.title 
driver.close() 

下面是完整的異常堆棧:

Traceback (most recent call last): 
    File "LoginLogout.py", line 4, in <module> 
    driver = webdriver.Firefox() 
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 80, in __init__ 
    self.binary, timeout) 
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 52, in __init__ 
    self.binary.launch_browser(self.profile, timeout=timeout) 
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser 
    self._wait_until_connectable(timeout=timeout) 
    File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 99, in _wait_until_connectable 
    "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. 

我有以下的環境設置

Mozilla Firefox瀏覽器:47.0

硒版本:2.53.6

Python版本:2.7.12

OS: Linux 4.4.0-31-generic#50 -Ubuntu SMP x86_64

+0

你可以在webdriver之外正常啓動Firefox嗎?這是否發生在Chrome或IE驅動程序? – Leustad

回答

1

硒正在使用FirefoxDriver而不是Marionette。幾個星期前,當我轉向Firefox 47.0並在那個時候切換到這個版本時,我遇到了這個問題。

以下link更全面地討論了這個問題。