Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Firefox quit unexpectedly." when running basic Selenium script in Python

I'm trying to scrape and print the HTML of a page using Selenium in Python, but every time I run it I get the error message

Firefox quit unexpectedly.

I'm new to Selenium, so any help would be greatly appreciated. I'm hoping for the simplest fix possible. Thank you!

My code:

import selenium
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://seleniumhq.org/')
print browser.page_source
like image 880
Tomero Avatar asked May 30 '15 17:05

Tomero


People also ask

How do I run Firefox in selenium Python?

To make Firefox work with Python selenium, you need to install the geckodriver. The geckodriver driver will start the real firefox browser and supports Javascript. Take a look at the selenium firefox code. First import the webdriver, then make it start firefox.

How do I run Firefox headless mode in selenium Python?

Headless Execution Firefox Driver It is quite simple to run your tests in the headless mode. You need simply to add the "--headless" argument to the FirefoxOptions object.

Can I use Selenium with Firefox?

Mozilla Firefox is one of the most widely used browsers in the world. It has enhanced features and is supported by a multitude of the latest testing tools and techniques. One such tool is Selenium.

How do I download Firefox using selenium?

Step 1: Selenium FirefoxDriver or Selenium GeckoDriver can be downloaded from the official GitHub repository of Mozilla. Go to the link and scroll towards the bottom of the page. Open the Assets menu and download the Selenium FirefoxDriver respective to your operating system. Step 2: Extract the downloaded file.


3 Answers

My experience since the upgrade to Firefox 38.x on Windows a couple of weeks back has been that it has a problem with Selenium 2.45.x. When invoking the browser it produces a "Firefox has stopped working" error which I have to close manually, at which point the test runs. Others have reported similar issues.

The solution that worked for me (apart from manually closing the error each time, which got old after a few days) was to uninstall the latest version of Firefox and downgrade to version 37.0.2 on the machine where I run the tests. Not ideal for security reasons, but OK if you're careful.

like image 192
Paul Drye Avatar answered Oct 18 '22 21:10

Paul Drye


Upgrading Selenium from 2.45 to 2.47 worked for me.

Selenium 2.46 fixes support for Firefox 38 (and looks like 39 as well). See the release notes

like image 21
tgf Avatar answered Oct 18 '22 23:10

tgf


What version of firefox are you using? firefox 36 started breaking for me with selenium version 2.43.0 . You can upgrade to 2.45 and check. https://code.google.com/p/selenium/issues/detail?id=8399 They mention at the end that there are fixes for ff 36 in 2.45. For ff 37 and beyond I'm not sure. I downgraded my ff to work with the version of selenium I had.

like image 30
Abhishek Nair Avatar answered Oct 18 '22 21:10

Abhishek Nair