Class WebDriverFactoryExtensions
- Namespace
- CSF.Extensions.WebDriver.Factories
- Assembly
- CSF.Extensions.WebDriver.dll
Extension methods for ICreatesWebDriverFromOptions.
public static class WebDriverFactoryExtensions
- Inheritance
-
WebDriverFactoryExtensions
- Inherited Members
Methods
GetWebDriver(ICreatesWebDriverFromOptions, WebDriverCreationOptionsCollection, Action<DriverOptions>)
Gets a WebDriver using the selected entry of a web drivers configuration.
public static WebDriverAndOptions GetWebDriver(this ICreatesWebDriverFromOptions factory, WebDriverCreationOptionsCollection configuration, Action<DriverOptions> supplementaryConfiguration = null)
Parameters
factory
ICreatesWebDriverFromOptionsThe WebDriver factory.
configuration
WebDriverCreationOptionsCollectionAn object which contains one or more WebDriver configurations as well as a value indicating which of those configurations is currently selected.
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 WebDriverCreationOptionsCollection instance must have a non-null/non-empty SelectedConfiguration and there must be an entry in DriverConfigurations of the same name as that selected configuration. That is the configuration instance which is treated as the "selected driver configuration". It will be passed to GetWebDriver(WebDriverCreationOptions, Action<DriverOptions>) and the result returned from this method.
The selected driver configuration object specifies both the OpenQA.Selenium.IWebDriver implementation type to use as well as any relevant options for that WebDriver.
Exceptions
- ArgumentNullException
If either parameter is null.
- ArgumentException
If any of:
- The selected DriverConfigurations entry is null
- The DriverType of the selected DriverConfigurations is null or empty
- The OptionsFactory of the selected DriverConfigurations is null
- The DriverType of the selected DriverConfigurations is set to
RemoteWebDriver
or to a type that is not shipped with Selenium but the OptionsType is null or empty
- TypeLoadException
Either DriverType or OptionsType of the selected DriverConfigurations are non-null/non-empty but no type can be found matching the specifed values.
- InvalidOperationException
If SelectedConfiguration is null or empty and there is not precisely one configuration within DriverConfigurations. Or if the
configuration
does not contain a configuration item with a key matching the SelectedConfiguration.
GetWebDriver(ICreatesWebDriverFromOptions, WebDriverCreationOptionsCollection, string, Action<DriverOptions>)
Gets a WebDriver using specified named WebDriver configuration.
public static WebDriverAndOptions GetWebDriver(this ICreatesWebDriverFromOptions factory, WebDriverCreationOptionsCollection configuration, string driverConfigName, Action<DriverOptions> supplementaryConfiguration = null)
Parameters
factory
ICreatesWebDriverFromOptionsThe WebDriver factory.
configuration
WebDriverCreationOptionsCollectionAn object which contains one or more WebDriver configurations.
driverConfigName
stringA string indicating the key of DriverConfigurations will be used to get a WebDriverCreationOptions for creating the driver.
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
There must be an entry in DriverConfigurations of the same name as driverConfigName
.
It will be passed to GetWebDriver(WebDriverCreationOptions, Action<DriverOptions>) and the result returned from this method.
The selected driver configuration object specifies both the OpenQA.Selenium.IWebDriver implementation type to use as well as any relevant options for that WebDriver.
Exceptions
- ArgumentNullException
If either parameter is null.
- ArgumentException
If any of:
driverConfigName
does not match any key of DriverConfigurations forconfiguration
.- The selected DriverConfigurations entry is null
- The DriverType of the selected DriverConfigurations is null or empty
- The OptionsFactory of the selected DriverConfigurations is null
- The DriverType of the selected DriverConfigurations is set to
RemoteWebDriver
or to a type that is not shipped with Selenium but the OptionsType is null or empty
- TypeLoadException
Either DriverType or OptionsType of the selected DriverConfigurations are non-null/non-empty but no type can be found matching the specifed values.