5

I was running some scripts I had developed in Selenium-Python today. They were working just fine. When I closed out a window & went to re-run a test, the Firefox browser that opened up would crash & my script would fail. This literally happened one second to the next. I wasn't sure what had changed to cause this.

I'm running Selenium 2.53 & Firefox 47 on my machine. Occasionally when I try to run my script again, I will get this run error in Pycharm:

File "C:\Python34\lib\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.

Normally I just get an error when I manually close the crashed FireFox browser that opens. Any ideas as to what occurred?

SneakersSO
  • 85
  • 1
  • 5

3 Answers3

2

I also had issues with Firefox 47 and Selenium. You could try reverting back to a previous version of Firefox and disabling updates.

Previous versions of Firefox and instructions on how to disable automatic updates can be found here: https://support.mozilla.org/en-US/kb/install-older-version-of-firefox

klips
  • 21
  • 1
2

According to Firefox 47 release notes (June 7, 2016):

Unresolved: Selenium WebDriver may cause Firefox to crash on startup, use Marionette WebDriver instead

darksaber
  • 31
  • 1
  • 5
2

I would like to slightly correct previous answer. Working example is below:

Preliminary:

  1. Download geckodriver.zip from https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver;
  2. Extract geckodriver.exe to the directory where this script is located.
  3. Run script:

    # -*- coding: utf-8 -*-
    
    import os
    from selenium import webdriver
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    
    firefox_capabilities = DesiredCapabilities.FIREFOX
    firefox_capabilities['marionette'] = True
    gecko = os.path.normpath(os.path.join(os.path.dirname(__file__), 'geckodriver'))
    browser = webdriver.Firefox(capabilities=firefox_capabilities, executable_path=gecko+'.exe')
    
    browser.get('http:///www.google.com')
    browser.close()
    # browser.quit()
    
Andrew
  • 720
  • 1
  • 6
  • 9