Table of Contents

Class FirefoxDriver

Namespace
OpenQA.Selenium.Firefox
Assembly
WebDriver.dll

Provides a way to access Firefox to run tests.

public class FirefoxDriver : RemoteWebDriver, IWebDriver, IDisposable, ISearchContext, IJavaScriptExecutor, IFindsById, IFindsByClassName, IFindsByLinkText, IFindsByName, IFindsByTagName, IFindsByXPath, IFindsByPartialLinkText, IFindsByCssSelector, ITakesScreenshot, IHasInputDevices, IHasCapabilities, IAllowsFileDetection
Inheritance
FirefoxDriver
Implements
Inherited Members

Examples

[TestFixture]
public class Testing
{
    private IWebDriver driver;

    [SetUp]
    public void SetUp()
    {
        driver = new FirefoxDriver();
    }

    [Test]
    public void TestGoogle()
    {
        driver.Navigate().GoToUrl("http://www.google.co.uk");
        /*
        *   Rest of the test
        */
    }

    [TearDown]
    public void TearDown()
    {
        driver.Quit();
    } 
}

Remarks

When the FirefoxDriver object has been instantiated the browser will load. The test can then navigate to the URL under test and start your test.

In the case of the FirefoxDriver, you can specify a named profile to be used, or you can let the driver create a temporary, anonymous profile. A custom extension allowing the driver to communicate to the browser will be installed into the profile.

Constructors

FirefoxDriver()

Initializes a new instance of the FirefoxDriver class.

public FirefoxDriver()

FirefoxDriver(FirefoxBinary, FirefoxProfile)

Initializes a new instance of the FirefoxDriver class for a given profile and binary environment.

public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile)

Parameters

binary FirefoxBinary

A FirefoxBinary object representing the operating system environmental settings used when running Firefox.

profile FirefoxProfile

A FirefoxProfile object representing the profile settings to be used in starting Firefox.

FirefoxDriver(FirefoxBinary, FirefoxProfile, TimeSpan)

Initializes a new instance of the FirefoxDriver class for a given profile, binary environment, and timeout value.

public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout)

Parameters

binary FirefoxBinary

A FirefoxBinary object representing the operating system environmental settings used when running Firefox.

profile FirefoxProfile

A FirefoxProfile object representing the profile settings to be used in starting Firefox.

commandTimeout TimeSpan

The maximum amount of time to wait for each command.

FirefoxDriver(FirefoxDriverService)

Initializes a new instance of the FirefoxDriver class using the specified driver service. Uses the Mozilla-provided Marionette driver implementation.

public FirefoxDriver(FirefoxDriverService service)

Parameters

service FirefoxDriverService

The FirefoxDriverService used to initialize the driver.

FirefoxDriver(FirefoxDriverService, FirefoxOptions, TimeSpan)

Initializes a new instance of the FirefoxDriver class using the specified options, driver service, and timeout. Uses the Mozilla-provided Marionette driver implementation.

public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options, TimeSpan commandTimeout)

Parameters

service FirefoxDriverService

The FirefoxDriverService to use.

options FirefoxOptions

The FirefoxOptions to be used with the Firefox driver.

commandTimeout TimeSpan

The maximum amount of time to wait for each command.

FirefoxDriver(FirefoxOptions)

Initializes a new instance of the FirefoxDriver class using the specified options. Uses the Mozilla-provided Marionette driver implementation.

public FirefoxDriver(FirefoxOptions options)

Parameters

options FirefoxOptions

The FirefoxOptions to be used with the Firefox driver.

FirefoxDriver(FirefoxProfile)

Initializes a new instance of the FirefoxDriver class for a given profile.

public FirefoxDriver(FirefoxProfile profile)

Parameters

profile FirefoxProfile

A FirefoxProfile object representing the profile settings to be used in starting Firefox.

FirefoxDriver(ICapabilities)

Initializes a new instance of the FirefoxDriver class for a given set of capabilities.

public FirefoxDriver(ICapabilities capabilities)

Parameters

capabilities ICapabilities

The ICapabilities object containing the desired capabilities of this FirefoxDriver.

Fields

AcceptUntrustedCertificates

Indicates whether the driver will accept untrusted SSL certificates.

public static readonly bool AcceptUntrustedCertificates

Field Value

bool

AssumeUntrustedCertificateIssuer

Indicates whether the driver assume the issuer of untrusted certificates is untrusted.

public static readonly bool AssumeUntrustedCertificateIssuer

Field Value

bool

BinaryCapabilityName

The name of the ICapabilities setting to use to define a custom location for the Firefox executable.

public static readonly string BinaryCapabilityName

Field Value

string

DefaultEnableNativeEvents

Indicates whether native events is enabled by default for this platform.

public static readonly bool DefaultEnableNativeEvents

Field Value

bool

DefaultPort

The default port on which to communicate with the Firefox extension.

public static readonly int DefaultPort

Field Value

int

ProfileCapabilityName

The name of the ICapabilities setting to use to define a custom Firefox profile.

public static readonly string ProfileCapabilityName

Field Value

string

Properties

Binary

Gets the FirefoxBinary and its details for subclasses

protected FirefoxBinary Binary { get; }

Property Value

FirefoxBinary

FileDetector

Gets or sets the IFileDetector responsible for detecting sequences of keystrokes representing file paths and names.

public override IFileDetector FileDetector { get; set; }

Property Value

IFileDetector

Remarks

The Firefox driver does not allow a file detector to be set, as the server component of the Firefox driver only allows uploads from the local computer environment. Attempting to set this property has no effect, but does not throw an exception. If you are attempting to run the Firefox driver remotely, use RemoteWebDriver in conjunction with a standalone WebDriver server.

Profile

Gets the FirefoxProfile that is currently in use by subclasses

protected FirefoxProfile Profile { get; }

Property Value

FirefoxProfile

Methods

CreateElement(string)

Creates a RemoteWebElement with the specified ID.

protected override RemoteWebElement CreateElement(string elementId)

Parameters

elementId string

The ID of this element.

Returns

RemoteWebElement

A RemoteWebElement with the specified ID. For the FirefoxDriver this will be a FirefoxWebElement.

PrepareEnvironment()

In derived classes, the PrepareEnvironment() method prepares the environment for test execution.

protected virtual void PrepareEnvironment()