Class WebDriverFromOptionsFactory
- Namespace
- CSF.Extensions.WebDriver.Factories
- Assembly
- CSF.Extensions.WebDriver.dll
Factory service which creates implementations of OpenQA.Selenium.IWebDriver from WebDriverCreationOptions.
public class WebDriverFromOptionsFactory : ICreatesWebDriverFromOptions
- Inheritance
-
WebDriverFromOptionsFactory
- Implements
- Inherited Members
- Extension Methods
Constructors
WebDriverFromOptionsFactory(IGetsWebDriverAndOptionsTypes, ILogger<WebDriverFromOptionsFactory>)
Initialises a new instance of WebDriverFromOptionsFactory.
public WebDriverFromOptionsFactory(IGetsWebDriverAndOptionsTypes typeProvider, ILogger<WebDriverFromOptionsFactory> logger)
Parameters
typeProvider
IGetsWebDriverAndOptionsTypesA type provider
logger
ILogger<WebDriverFromOptionsFactory>A logger
Exceptions
- ArgumentNullException
If any parameter is null.
Methods
GetWebDriver(WebDriverCreationOptions, Action<DriverOptions>)
Gets a WebDriver using the settings from the specified WebDriver configuration object.
public WebDriverAndOptions GetWebDriver(WebDriverCreationOptions options, Action<DriverOptions> supplementaryConfiguration = null)
Parameters
options
WebDriverCreationOptionsAn object indicating which WebDriver implementation to use and how the WebDriver should be configured.
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 instance and the OpenQA.Selenium.DriverOptions which were used to create it.
Remarks
The WebDriver configuration object specifies both the OpenQA.Selenium.IWebDriver implementation type to use as well as any relevant options for that WebDriver.
Exceptions
- ArgumentNullException
If
options
is null.- ArgumentException
If any of:
- The DriverType of the
options
is null or empty - The OptionsFactory of the
options
is null - The DriverType of the
options
is set to an implementation of OpenQA.Selenium.IWebDriver which does not expose a public constructor which takes a single parameter of type OpenQA.Selenium.DriverOptions (or a more derived type). Such WebDriver implementations will require a custom factory, indicated by DriverFactoryType - The DriverFactoryType of the
options
is not null, but the implementation of ICreatesWebDriverFromOptions indicated by that type did not return an OpenQA.Selenium.IWebDriver instance
- The DriverType of the
- TypeLoadException
Either DriverType or DriverFactoryType of the
options
are non-null/non-empty but no type can be found matching the specifed values.