Class WebDriverFactory
- Namespace
- CSF.Extensions.WebDriver
- Assembly
- CSF.Extensions.WebDriver.dll
A 'universal web driver factory' which uses the options pattern to inject a WebDriverCreationOptionsCollection and forward that information to a. ICreatesWebDriverFromOptions.
public class WebDriverFactory : IGetsWebDriver
- Inheritance
-
WebDriverFactory
- Implements
- Inherited Members
Constructors
WebDriverFactory(IOptions<WebDriverCreationOptionsCollection>, ICreatesWebDriverFromOptions)
Initialises a new instance of WebDriverFactory.
public WebDriverFactory(IOptions<WebDriverCreationOptionsCollection> options, ICreatesWebDriverFromOptions factory)
Parameters
options
IOptions<WebDriverCreationOptionsCollection>The application's options related to creation of web drivers.
factory
ICreatesWebDriverFromOptionsThe underlying driver factory
Exceptions
- ArgumentNullException
If either parameter is null.
Methods
GetDefaultWebDriver(Action<DriverOptions>)
Gets an OpenQA.Selenium.IWebDriver using the driver configuration indicated by the SelectedConfiguration.
public WebDriverAndOptions GetDefaultWebDriver(Action<DriverOptions> supplementaryConfiguration = null)
Parameters
supplementaryConfiguration
Action<DriverOptions>An optional action which further-configures the WebDriver options before the driver is created.
Returns
- WebDriverAndOptions
An object containing both a WebDriver and the options which were used to create it.
Remarks
The supplementaryConfiguration
can be useful for customising the WebDriver options in a manner specific to a single WebDriver.
For example some remote WebDriver providers offer a facility to 'tag' the WebDriver with a current test/scenario name. This is done by adding
additional options to the DriverOptions, specific to that scenario.
GetWebDriver(string, Action<DriverOptions>)
Gets an OpenQA.Selenium.IWebDriver using the named driver configuration.
public WebDriverAndOptions GetWebDriver(string configurationName, Action<DriverOptions> supplementaryConfiguration = null)
Parameters
configurationName
stringThe driver configuration name.
supplementaryConfiguration
Action<DriverOptions>An optional action which further-configures the WebDriver options before the driver is created.
Returns
- WebDriverAndOptions
An object containing both a WebDriver and the options which were used to create it.
Remarks
The configurationName
must correspond to a key within the DriverConfigurations
collection.
The supplementaryConfiguration
can be useful for customising the WebDriver options in a manner specific to a single WebDriver.
For example some remote WebDriver providers offer a facility to 'tag' the WebDriver with a current test/scenario name. This is done by adding
additional options to the DriverOptions, specific to that scenario.