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, IHasInputDevices, IHasCapabilities, IAllowsFileDetection, ITakesScreenshot
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(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

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

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.

GetScreenshot()

Gets a Screenshot object representing the image of the page on the screen.

public Screenshot GetScreenshot()

Returns

Screenshot

A Screenshot object containing the image.

PrepareEnvironment()

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

protected virtual void PrepareEnvironment()

StartClient()

Starts the command executor, enabling communication with the browser.

protected override void StartClient()

StopClient()

Stops the command executor, ending further communication with the browser.

protected override void StopClient()