Skip to content

Instantly share code, notes, and snippets.

@parkerl
Created January 20, 2012 22:19
Show Gist options
  • Save parkerl/1649944 to your computer and use it in GitHub Desktop.
Save parkerl/1649944 to your computer and use it in GitHub Desktop.
Configuring selenium to use a legacy Firefox version in Rails applications.

Motivation

We recently were working on a project where the version of Firefox on the development machines was causing acceptance tests running on Capybara and Selenium to fail and/or hang erroneously. The solution was to point Selenium at a custom version of Firefox. We also added the Firefox binaries to the application git repo so that all devs could run against a known good version of Firefox.

Solution

  1. Download the desired version of Firefox from ftp://ftp.mozilla.org/pub/firefox/releases/

  2. Put Firefox.app in your rails app somewhere like ./bin/spec/macosx/

  3. Add an intializer called selenium.rb to config/initalizers and put in the following code (customized to where you put Firefox)

if Rails.env.test?
    require 'selenium-webdriver'
    Selenium::WebDriver::Firefox::Binary.path= Rails.root.to_s + '/bin/spec/macosx/Firefox.app/Contents/MacOS/firefox-bin'
end
@jpgeek
Copy link

jpgeek commented Jan 14, 2013

Thanks! worked like a charm

@afarriaga
Copy link

I've done this before but putting it in an initializer seems better. Thanks!

@IvikGH
Copy link

IvikGH commented Feb 12, 2018

Thanks!
Still actual. I've put the path to environment variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment