Table of Contents

Interface ICreatesWebDriverFromOptions

Namespace
CSF.Extensions.WebDriver.Factories
Assembly
CSF.Extensions.WebDriver.dll

A service that gets an instance of OpenQA.Selenium.IWebDriver from a configuration object.

public interface ICreatesWebDriverFromOptions
Extension Methods

Remarks

This service could be thought of as 'a general WebDriver factory'. This allows the creation of any implementation of WebDriver from just configuration information.

The purpose of this service is to make it easier to write applications (or browser-based tests) which test using a variety of WebDriver implementations (such as a variety of browsers). By using this service, the application or test need not hard-code the logic to create the WebDriver instances, they can be input from configuration data.

Methods

GetWebDriver(WebDriverCreationOptions, Action<DriverOptions>)

Gets a WebDriver using the settings from the specified WebDriver configuration object.

WebDriverAndOptions GetWebDriver(WebDriverCreationOptions options, Action<DriverOptions> supplementaryConfiguration = null)

Parameters

options WebDriverCreationOptions

An 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
TypeLoadException

Either DriverType or DriverFactoryType of the options are non-null/non-empty but no type can be found matching the specifed values.