0

I have a simple python script which does not work:

#!/usr/bin/env python

from selenium import webdriver


browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/')

However I receive this error when I try to run it:

Traceback (most recent call last):
  File "./test.py", line 5, in <module>
    browser = webdriver.Firefox()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 103, in __init__
    self.binary, timeout)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 51, 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 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.

I am running selenium version:

Name: selenium
Version: 2.53.2

Firefox version:

ii  firefox-mozilla-build            14.0.1-0ubuntu1                  amd64        Mozilla Firefox, official Mozilla build, packaged for Ubuntu by the Ubuntuzilla project.
user3270211
  • 915
  • 4
  • 20
  • 42
  • Have you tried the solutions listed here? http://stackoverflow.com/questions/26070834/how-to-fix-selenium-webdriverexception-the-browser-appears-to-have-exited-befor – lonewaft May 24 '16 at 19:55
  • @lonewaft Just tried that. Did not solve the problem. I believe there is a problem between the version of selenium and firefox. But havent found any documentation about which version of selenium support firefox, etc. – user3270211 May 24 '16 at 19:58
  • Just a side note: You should update your browser, it is ages old. The recent version is 46.0.1. – Klaus D. May 24 '16 at 20:06
  • I have tried multiple versions of Firefox. Newest, older and so on to make it work. – user3270211 May 24 '16 at 20:15

1 Answers1

0

In order to use the most up to date selenium, you need to use most up to date firefox. Your firefox version is severely out of date.

Then, make sure you can open firefox from command line. Simply type firefoxin your terminal.

And finally, make sure you update python's selenium: sudo pip install -U selenium.

user2272115
  • 986
  • 1
  • 10
  • 22