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
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.
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.
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.
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.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With