This does not use generics, as your example, but instead works like dependency injection.
You need a method to create an instance of the web server.
public class DriverFactory
{
public IWebDriver Driver { get; set; }
public enum DriverType
{
IE,
Firefox,
Chrome
}
public IWebDriver GetDriver(DriverType typeOfDriver)
{
if (typeOfDriver == DriverType.IE) return new InternetExplorerDriver();
if (typeOfDriver == DriverType.Chrome) return new ChromeDriver();
return new FirefoxDriver();
}
}
Then call from your installation:
[Setup]
public void CreateDriver()
{
var driverFactory = new DriverFactory();
this.driver = driverFactory.GetDriver(DriverType.Chrome);
}
You can inherit a class:
public class TestWithMultipleBrowsers : DriverFactory
source
share