0

I'm trying to run Selenium with Python 3.4 on a local machine with Gnome desktop and Firefox 47. However, the most basic task is already failing, i.e. opening the browser window. I know that this question has been asked on several SO post now, but none of the answers is solving the problem.

I simply installed Selenium with pip install selenium. When I run

from selenium import webdriver
driver= webdriver.Firefox()

I get the following traceback:

WebDriverException                        Traceback (most recent call last)
<ipython-input-2-b517b01341f3> in <module>()
----> 1 driver= webdriver.Firefox()

/usr/lib/python3.4/site-packages/selenium/webdriver/firefox/webdriver.py in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy, executable_path, firefox_options)
     79 
     80             executor = ExtensionConnection("127.0.0.1", self.profile,
---> 81                                            self.binary, timeout)
     82             RemoteWebDriver.__init__(self,
     83                 command_executor=executor,

/usr/lib/python3.4/site-packages/selenium/webdriver/firefox/extension_connection.py in __init__(self, host, firefox_profile, firefox_binary, timeout)
     49         self.profile.add_extension()
     50 
---> 51         self.binary.launch_browser(self.profile, timeout=timeout)
     52         _URL = "http://%s:%d/hub" % (HOST, PORT)
     53         RemoteConnection.__init__(

/usr/lib/python3.4/site-packages/selenium/webdriver/firefox/firefox_binary.py in launch_browser(self, profile, timeout)
     66 
     67         self._start_from_profile_path(self.profile.path)
---> 68         self._wait_until_connectable(timeout=timeout)
     69 
     70     def kill(self):

/usr/lib/python3.4/site-packages/selenium/webdriver/firefox/firefox_binary.py in _wait_until_connectable(self, timeout)
     96             if self.process.poll() is not None:
     97                 # Browser has exited
---> 98                 raise WebDriverException("The browser appears to have exited "
     99                       "before we could connect. If you specified a log_file in "
    100                       "the FirefoxBinary constructor, check it for details.")

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 have already tried using pyvirtualdisplay and setting the $DISPLAY environment variable, but nothing helped.

Jarno
  • 6,243
  • 3
  • 42
  • 57

1 Answers1

1

Since firefox update to version 47 selenium is not running any more. A work around is using Marionette. That's also recommended by Mozilla.


An alternative you can use is using older firefox version:

You can download the binary here and use it here:

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('path/to/binary')
driver = webdriver.Firefox(firefox_binary=binary)
trantu
  • 1,089
  • 8
  • 17
  • Are there other issues with Firefox 47? Even with the new driver that seems to work for most tasks, I can't select elements from a dropdown list. – Jarno Jun 15 '16 at 11:37
  • I updated my answer. You could try it. – trantu Jun 15 '16 at 12:54
  • Well I have downloaded the binary but when I launch it, it still says it's Firefox 47. – Jarno Jun 15 '16 at 13:05
  • You already set `binary = FirefoxBinary('path/to/firefox/firefox')` ? – trantu Jun 15 '16 at 13:10
  • Ok it launched 47 when I executed the the terminal but when using it in selenium it launches the old version and the select is actually working. Thanks a lot! – Jarno Jun 15 '16 at 13:17