Let\'s say I Have code:
namespace SeleniumTests
{
[TestFixture(typeof(FirefoxDriver))]
[TestFixture(typeof(InternetExplorerDriver))]
public clas
This doesn't use generics like your example but instead kind of works like dependency injection.
You need a method to create the instance of the webdriver.
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(); // return firefox by default
}
}
Then call from your setup:
[Setup]
public void CreateDriver()
{
var driverFactory = new DriverFactory();
this.driver = driverFactory.GetDriver(DriverType.Chrome);
}
You can inherit the class:
public class TestWithMultipleBrowsers : DriverFactory