Class FirefoxDriver
Provides a way to access Firefox to run tests.
public class FirefoxDriver : RemoteWebDriver, IWebDriver, ISearchContext, IDisposable, IJavaScriptExecutor, IFindsById, IFindsByClassName, IFindsByLinkText, IFindsByName, IFindsByTagName, IFindsByXPath, IFindsByPartialLinkText, IFindsByCssSelector, ITakesScreenshot, IHasInputDevices, IHasCapabilities, IHasWebStorage, IHasLocationContext, IHasApplicationCache, IAllowsFileDetection, IHasSessionId, IActionExecutor
- 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.
[Obsolete("FirefoxDriver should not be constructed with a FirefoxBinary object. Use FirefoxOptions instead. This constructor will be removed in a future release.")]
public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile)
Parameters
binary
FirefoxBinaryA FirefoxBinary object representing the operating system environmental settings used when running Firefox.
profile
FirefoxProfileA 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.
[Obsolete("FirefoxDriver should not be constructed with a FirefoxBinary object. Use FirefoxOptions instead. This constructor will be removed in a future release.")]
public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout)
Parameters
binary
FirefoxBinaryA FirefoxBinary object representing the operating system environmental settings used when running Firefox.
profile
FirefoxProfileA FirefoxProfile object representing the profile settings to be used in starting Firefox.
commandTimeout
TimeSpanThe 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
FirefoxDriverServiceThe FirefoxDriverService used to initialize the driver.
FirefoxDriver(FirefoxDriverService, FirefoxOptions)
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)
Parameters
service
FirefoxDriverServiceThe FirefoxDriverService to use.
options
FirefoxOptionsThe FirefoxOptions to be used with the Firefox 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
FirefoxDriverServiceThe FirefoxDriverService to use.
options
FirefoxOptionsThe FirefoxOptions to be used with the Firefox driver.
commandTimeout
TimeSpanThe 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
FirefoxOptionsThe FirefoxOptions to be used with the Firefox driver.
FirefoxDriver(FirefoxProfile)
Initializes a new instance of the FirefoxDriver class for a given profile.
[Obsolete("FirefoxDriver should not be constructed with a FirefoxProfile object. Use FirefoxOptions instead. This constructor will be removed in a future release.")]
public FirefoxDriver(FirefoxProfile profile)
Parameters
profile
FirefoxProfileA 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.
[Obsolete("FirefoxDriver should not be constructed with a raw ICapabilities or DesiredCapabilities object. Use FirefoxOptions instead. This constructor will be removed in a future release.")]
public FirefoxDriver(ICapabilities capabilities)
Parameters
capabilities
ICapabilitiesThe ICapabilities object containing the desired capabilities of this FirefoxDriver.
FirefoxDriver(string)
Initializes a new instance of the FirefoxDriver class using the specified path to the directory containing geckodriver.exe.
public FirefoxDriver(string geckoDriverDirectory)
Parameters
geckoDriverDirectory
stringThe full path to the directory containing geckodriver.exe.
FirefoxDriver(string, FirefoxOptions)
Initializes a new instance of the FirefoxDriver class using the specified path to the directory containing geckodriver.exe and options.
public FirefoxDriver(string geckoDriverDirectory, FirefoxOptions options)
Parameters
geckoDriverDirectory
stringThe full path to the directory containing geckodriver.exe.
options
FirefoxOptionsThe FirefoxOptions to be used with the Firefox driver.
FirefoxDriver(string, FirefoxOptions, TimeSpan)
Initializes a new instance of the FirefoxDriver class using the specified path to the directory containing geckodriver.exe, options, and command timeout.
public FirefoxDriver(string geckoDriverDirectory, FirefoxOptions options, TimeSpan commandTimeout)
Parameters
geckoDriverDirectory
stringThe full path to the directory containing geckodriver.exe.
options
FirefoxOptionsThe FirefoxOptions to be used with the Firefox driver.
commandTimeout
TimeSpanThe maximum amount of time to wait for each command.
Fields
AcceptUntrustedCertificates
Indicates whether the driver will accept untrusted SSL certificates.
public static readonly bool AcceptUntrustedCertificates
Field Value
AssumeUntrustedCertificateIssuer
Indicates whether the driver assume the issuer of untrusted certificates is untrusted.
public static readonly bool AssumeUntrustedCertificateIssuer
Field Value
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
DefaultEnableNativeEvents
Indicates whether native events is enabled by default for this platform.
public static readonly bool DefaultEnableNativeEvents
Field Value
DefaultPort
The default port on which to communicate with the Firefox extension.
public static readonly int DefaultPort
Field Value
ProfileCapabilityName
The name of the ICapabilities setting to use to define a custom Firefox profile.
public static readonly string ProfileCapabilityName
Field Value
Properties
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
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.
IsMarionette
Gets a value indicating whether the Firefox driver instance uses Mozilla's Marionette implementation. This is a temporary property and will be removed when Marionette is available for the release channel of Firefox.
public bool IsMarionette { get; }
Property Value
Methods
PrepareEnvironment()
In derived classes, the PrepareEnvironment() method prepares the environment for test execution.
protected virtual void PrepareEnvironment()