Reputation: 11603
I have the following script
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://localhost:8000')
assert 'Django' in browser.title
I get the following error
$ python3 functional_tests.py
Traceback (most recent call last): File "functional_tests.py", line 3, in <module>
browser = webdriver.Firefox() File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 80, in __init__
self.binary, timeout) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 52, in __init__
self.binary.launch_browser(self.profile, timeout=timeout) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
self._wait_until_connectable(timeout=timeout) File "/usr/local/lib/python3.5/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.
pip3 list
shows selenium (2.53.6)
.
firefox -v
shows Mozilla Firefox 47.0
.
Upvotes: 1
Views: 2119
Reputation: 1461
The last version of Firefox is not working properly with selenium. Try with 46 or 45.
You can download here: ftp.mozilla.org/pub/firefox/releases
or sudo apt-get install firefox=45.0.2+build1-0ubuntu1
You can also do this graphically as shown here http://www.howtogeek.com/117929/how-to-downgrade-packages-on-ubuntu/
Upvotes: 0
Reputation: 1196
I struggled with this problem as well, and I was unhappy with having to use older versions of Firefox. Here's my solution that uses the latest version of Firefox. It however involves several steps
Step 1. Download v0.9.0 Marionette, the next generation of FirefoxDriver, from this location: https://github.com/mozilla/geckodriver/releases/download/v0.9.0/geckodriver-v0.9.0-linux64.tar.gz
Step 2. Extract the file to a desired folder, and rename it to "wires". In my case I created a folder named "add_to_system_path" under Documents. So the file is in Documents/add_to_system_path/wires (also make sure that the wires file is executable under its properties)
Step 3. Create a file named ".pam_environment" under your home folder, and then adding this line on it and save
PATH DEFAULT=${PATH}:/absolute/path/to/the/folder/where/wires/is/saved
What this does is it tells ubuntu to add the enumerated dir in .pam_environment to your system path
Step 4. Save the file, log out of your user session, and log back in. This is necessary to do so that the files in the newly added system path is recognized by ubuntu
Step 5. Use the code below to instantiate the browser instance:
`
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
capabilities = DesiredCapabilities.FIREFOX
capabilities["marionette"] = True
browser = webdriver.Firefox(capabilities=capabilities)
browser.get('http://your-target-url')`
Firefox should now be able to instantiate as usual.
Upvotes: 4