|
|
Firefox Driver
Everything you ever wanted to know about the Firefox driver but were afraid to ask. See below for instructions on how to install the FirefoxDriver.
Important System Properties
The following system properties (read using System.getProperty()) are used by the FirefoxDriver:
| Property | What it means |
| webdriver.firefox.bin | The location of the binary used to control firefox. |
| webdriver.firefox.development | When using the FirefoxLauncher class to create the profile, this indicates that you are using the development version of WebDriver (that is, one that is checked out from source) |
| webdriver.firefox.profile | The name of the profile to use when starting firefox. This defaults to WebDriver |
| webdriver.firefox.useExisting | Use a running instance of firefox if one is present |
Normally the Firefox binary is assumed to be in the default location for your particular operating system:
| OS | Expected Location of Firefox |
| Linux | firefox (found using "which") |
| Mac | /Applications/Firefox.app/Contents/MacOS/firefox |
| Windows | %PROGRAMFILES%\Mozilla Firefox\firefox.exe |
The default profile name is WebDriver (the casing matters!)
Installing a Downloaded Binary
The "wedriver-firefox.zip" which may be downloaded from the website, contains all the dependencies (including the common library) required to run the FirefoxDriver. In order to use it:
- Copy all the "jar" files on to your classpath.
- Create a "WebDriver" profile. The case of the profile name matters!
- firefox -ProfileManager
- "firefox" here is the full path to the Firefox 2 binary installed on your system.
- Click the "Create Profile" button.
- Follow the wizard, accepting the defaults offered, except for the profile name, which is "WebDriver" (without the quotes, but with the same StudlyCaps!)
- Start the new profile. This can be done one of two ways:
- firefox -ProfileManager and double-clicking on the WebDriver profile in the list shown
- firefox -P WebDriver
# Install the FirefoxDriver XPI by dragging the XPI on to the instance of Firefox using the WebDriver profile and following the on-screen prompts.
Once this has been done, you should be able to quit Firefox and the FirefoxDriver should work as expected.
Installing the Quick Way From Source (with Ruby)
There is a plan to make the FirefoxDriver installable as a simple XPI. Until then, you'll need Ruby and rake installed on your machine, then (after quitting any open instances of Firefox) simply run:
rake install_firefox
This assumes that your installation of Firefox 2 is pretty standard. On Windows, this means that it should be installed in the default location ("C:\Program Files\Mozilla Firefox") and on the Mac under "/Applications/Firefox". On Linux, it is assumed that firefox is available on the default PATH. If your firefox is installed in a custom location, then set the "firefox" variable to be the firefox binary to use:
rake install_firefox firefox="d:\apps\mozilla firefox\firefox"
After the installation is completed, Firefox should start using the new WebDriver profile. Go to "Tools->Add-ons" and check that there's an extension called "Firefox WebDriver" installed. Carry on reading below if it's not!
Installing the Quick Way From Source (with Java)
There is a FirefoxLauncher class that can be run. It takes a single argument, which is the name of the profile to create. If no argument is given, then the profile will be called WebDriver. The FirefoxLauncher will make use of the "webdriver.firefox.development" system property to determine whether or not we should use a pre-built XPI of WebDriver or whether we are using a development build (that is, the extension used will be the version obtained using from a CheckOut) Example usage looks like:
java -cp common/build/webdriver-common.jar:firefox/build/webdriver-firefox.jar -Dwebdriver.firefox.development="/home/foo/webdriver/trunk/firefox/src/extension" com.googlecode.webdriver.firefox.FirefoxLauncher
The equivalent in an Ant build file would be:
<target name="install_firefox_driver">
<java classname="com.googlecode.webdriver.firefox.FirefoxLauncher" fork="yes">
<sysproperty key="webdriver.firefox.development" value="/home/foo/webdriver/trunk/firefox/src/extension"/>
<arg value="WebDriver"/>
<classpath>
<pathelement location="common/build/webdriver-common.jar"/>
<pathelement location="firefox/build/webdriver-firefox.jar"/>
</classpath>
</java>
</target>Installing the Long Way
If the quick way doesn't work for you, or you'd like to understand more about what to do, you'll need to install the extension by hand. This isn't as terrifying as you might think:
- Find out where your profile directory ($PROFILE_DIR) is. The best guide for that is here: http://www.mozilla.org/support/firefox/profile
- Create a new "WebDriver" profile. The camel case matters!
- This is done using firefox -ProfileManager
- Or by following the instructions from the page mentioned above
- Create a file called fxdriver@googlecode.com in $PROFILE_DIR/xxxxxxxx.WebDriver/extensions/ The contents of this file should be a single line, containing the absolute path to the FirefoxDriver's extension directory (firefox/src/extension)
Pros
- Runs in a real browser and supports Javascript
- Not as fast as the HtmlUnitDriver, but faster than the InternetExplorerDriver
Cons
- Currently requires the "WebDriver" profile to be set up in Firefox
Sign in to add a comment
