Table of Contents

Class WebDriverCreationOptionsCollection

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

Describes a collection of configurations which may be used with ICreatesWebDriverFromOptions to get a WebDriver.

public class WebDriverCreationOptionsCollection
Inheritance
WebDriverCreationOptionsCollection
Inherited Members

Remarks

This object additionally has a property that indicates which of those configurations is 'currently selected': SelectedConfiguration. This enables techniques in which many WebDriver configurations are available, such as in an appsettings.json file and a parameter is used to choose between them by name. Such a value might be provided via a command-line argument, for example.

Properties

DriverConfigurations

Gets or sets a name/value collection of WebDriverCreationOptions instances, containing all of the WebDriver configurations which are available.

public IDictionary<string, WebDriverCreationOptions> DriverConfigurations { get; set; }

Property Value

IDictionary<string, WebDriverCreationOptions>

SelectedConfiguration

Gets or sets the key of a WebDriver configuration which is currently selected.

public string SelectedConfiguration { get; set; }

Property Value

string

Remarks

When set, this value must correspond to a key of the collection DriverConfigurations. If appropriately set, then the current WebDriverCreationOptionsCollection instance may be used as the parameter to GetWebDriver(ICreatesWebDriverFromOptions, WebDriverCreationOptionsCollection, Action<DriverOptions>) in order to get a WebDriver from the currently selected configuration.

Methods

GetSelectedConfiguration()

Gets the WebDriverCreationOptions from the DriverConfigurations which is considered 'currently selected'.

public WebDriverCreationOptions GetSelectedConfiguration()

Returns

WebDriverCreationOptions

A WebDriverCreationOptions

Remarks

There are two ways in which an item in DriverConfigurations can be the currently-selected one:

  • The SelectedConfiguration is non-null and not an empty string. The driver configuration with a key matching the name of the selected configuration is the currently selected one.
  • If SelectedConfiguration is null or empty but there is precisely one item present within DriverConfigurations; that single configuration is considered to be currently selected.

Exceptions

InvalidOperationException

If SelectedConfiguration is not null or empty, but there is no item within DriverConfigurations with a key matching the selected configuration or if SelectedConfiguration is either null or empty and there is not precisely one configuration within DriverConfigurations.