Class WebDriverTypesProvider
- Namespace
- CSF.Extensions.WebDriver.Factories
- Assembly
- CSF.Extensions.WebDriver.dll
Provide type for OpenQA.Selenium.IWebDriver and OpenQA.Selenium.DriverOptions types.
public class WebDriverTypesProvider : IGetsWebDriverAndOptionsTypes
- Inheritance
-
WebDriverTypesProvider
- Implements
- Inherited Members
Remarks
Instances of this type perform internal caching, to avoid repeatedly re-using the computationally-expensive functionality of IGetsWebDriverWithDeterministicOptionsTypes. This should be safe under almost all circumstances, unless dynamic assembly unload/reload occurs.
Constructors
WebDriverTypesProvider(IGetsWebDriverWithDeterministicOptionsTypes)
Initialises a new instance of WebDriverTypesProvider.
public WebDriverTypesProvider(IGetsWebDriverWithDeterministicOptionsTypes deterministicWebDriverTypesScanner)
Parameters
deterministicWebDriverTypesScanner
IGetsWebDriverWithDeterministicOptionsTypesA scanner for the WebDriver types which imply a deterministic options type.
Exceptions
- ArgumentNullException
If
deterministicWebDriverTypesScanner
is null.
Methods
GetWebDriverFactoryType(string)
Gets the Type for an implementation of ICreatesWebDriverFromOptions, for when a third-party factory is to be used.
public Type GetWebDriverFactoryType(string typeName)
Parameters
typeName
stringThe assembly qualified name of the factory type.
Returns
Exceptions
- ArgumentException
If
typeName
is null or whitespace, or if it corresponds to a type which does not implement ICreatesWebDriverFromOptions.- TypeLoadException
If the type specified by
typeName
cannot be loaded.
GetWebDriverOptionsType(Type, string)
Gets the Type for an implementation of OpenQA.Selenium.DriverOptions from an optional string type name and the implementation-type of the OpenQA.Selenium.IWebDriver which will be consuming those options.
public Type GetWebDriverOptionsType(Type driverType, string typeName = null)
Parameters
driverType
TypeThe type of OpenQA.Selenium.IWebDriver which will be consuming these options.
typeName
stringAn optional name of a type which implements OpenQA.Selenium.DriverOptions; see the remarks for more information.
Returns
- Type
A DriverOptions type.
Remarks
Under some circumstances, the typeName
parameter may be null and the type will
still be correctly determined. That is because a number of OpenQA.Selenium.IWebDriver implementation types imply a
deterministic OpenQA.Selenium.DriverOptions type via their constructor signature.
For such WebDriver implementation types, if the type name is omitted then the options type will be returned based upon the implied options type, which the driver type takes in its constructor.
Additionally, for all concrete OpenQA.Selenium.DriverOptions implementations which are shipped with Selenium, when
typeName
is specified it needs only be a short type name, equivalent to Name.
For third-party driver options implementations, this must be an assembly-qualified name, such that the type may
be found using GetType(string).
Exceptions
- ArgumentNullException
If
driverType
is null.- ArgumentException
If
typeName
is specified, but does not correspond to a type which derives from OpenQA.Selenium.DriverOptions, or iftypeName
is null but thedriverType
is not a type which implies a driver options type.- TypeLoadException
If the type specified by
typeName
cannot be loaded.
GetWebDriverType(string)
Gets the Type for an implementation of OpenQA.Selenium.IWebDriver, from a string type name.
public Type GetWebDriverType(string typeName)
Parameters
typeName
stringThe name of the type.
Returns
- Type
A WebDriver type.
Remarks
For WebDriver implementations which are shipped with Selenium, all that is required is the
short name, corresponding to Name.
For WebDriver implementations that are not part of the Selenium.WebDriver
NuGet package,
this should be an assembly-qualified type name, such that the type could be located with
GetType(string).
Exceptions
- ArgumentException
If
typeName
is null or whitespace, or if it corresponds to a type which does not implement OpenQA.Selenium.IWebDriver.- TypeLoadException
If the type specified by
typeName
cannot be loaded.