-
Notifications
You must be signed in to change notification settings - Fork 0
WebDriverFactories
Craig Fowler edited this page Feb 1, 2018
·
1 revision
A web driver factory is a type which implements the following interface:
public interface ICreatesWebDriver
{
IWebDriver CreateWebDriver(IDictionary<string,object> requestedCapabilities = null,
IGetsBrowserFlags flagsProvider = null,
string scenarioName = null);
}It provides a mechanism by which to encapsulate and refer abstractly to logic which creates instances of IWebDriver.
The parameters accepted by the method shown above are all optional:
- A set of capabilities requested at the time the web driver is created
- These override any capabilities which were set within the factory itself
- A type which provides the web browser flags for the web driver
- A name for the current testing scenario
- Some web driver implementations are able to make use of this information
- There is no harm in passing it when it will not be used.
WebDriverExtras provides a number of factories, all in the CSF.WebDriverExtras.Factories namespace:
- ChromeDriverFactory
- FirefoxDriverFactory
- RemoteDriverFactory
- SauceConnectDriverFactory
These may be used alone, but they become more powerful when combined with a mechanism which selects and instantiates an appropriate factory type. This constructed factory may then be injected into logic which requires web drivers (such as testing code), freeing the test code of any responsibility for how a web driver is created.