View Source

# module selenium-webdriver/firefox

Defines the WebDriver client for Firefox. Each FirefoxDriver instance will be created with an anonymous profile, ensuring browser historys do not share session data (cookies, history, cache, offline storage, etc.)

Customizing the Firefox Profile

The `Profile` class may be used to configure the browser profile used with WebDriver, with functions to install additional extensions, configure browser preferences, and more. For example, you may wish to include Firebug:

    var firefox = require('selenium-webdriver/firefox');

    var profile = new firefox.Profile();
    profile.addExtension('/path/to/firebug.xpi');
    profile.setPreference('extensions.firebug.showChromeErrors', true);

    var options = new firefox.Options().setProfile(profile);
    var driver = new firefox.Driver(options);

The `Profile` class may also be used to configure WebDriver based on a pre-existing browser profile:

    var profile = new firefox.Profile(
        '/usr/local/home/bob/.mozilla/firefox/3fgog75h.testing');
    var options = new firefox.Options().setProfile(profile);
    var driver = new firefox.Driver(options);

The FirefoxDriver will never modify a pre-existing profile; instead it will create a copy for it to modify. By extension, there are certain browser preferences that are required for WebDriver to function properly and they will always be overwritten.

Using a Custom Firefox Binary

On Windows and OSX, the FirefoxDriver will search for Firefox in its default installation location:

- Windows: C:\Program Files and C:\Program Files (x86).
- Mac OS X: /Applications/Firefox.app

For Linux, Firefox will be located on the PATH: `$(where firefox)`.

You can configure WebDriver to start use a custom Firefox installation with the `Binary` class:

    var firefox = require('selenium-webdriver/firefox');
    var binary = new firefox.Binary('/my/firefox/install/dir/firefox-bin');
    var options = new firefox.Options().setBinary(binary);
    var driver = new firefox.Driver(options);

Remote Testing

You may customize the Firefox binary and profile when running against a remote Selenium server. Your custom profile will be packaged as a zip and transfered to the remote host for use. The profile will be transferred once for each new session. The performance impact should be minimal if you've only configured a few extra browser preferences. If you have a large profile with several extensions, you should consider installing it on the remote host and defining its path via the `Options` class. Custom binaries are never copied to remote machines and must be referenced by installation path.

    var options = new firefox.Options()
        .setProfile('/profile/path/on/remote/host')
        .setBinary('/install/dir/on/remote/host/firefox-bin');

    var driver = new (require('selenium-webdriver')).Builder()
        .forBrowser('firefox')
        .usingServer('http://127.0.0.1:4444/wd/hub')
        .setFirefoxOptions(options)
        .build();

## Types

Binary

  Provides a mechanism to configure and launch Firefox in a subprocess for use with WebDriver.

Driver

  A WebDriver client for Firefox.

Options

  Configuration options for the FirefoxDriver.

Profile

  Models a Firefox proifle directory for use with the FirefoxDriver.