Updating .NET test driver factory to handle remote driver
@@ -81,29 +81,25 @@ public IWebDriver CreateDriverWithOptions(Type driverType, DriverOptions driverO
options = GetDriverOptions<ChromeOptions>(driverType, driverOptions);
service = CreateService<ChromeDriverService>(driverType);
}
-
- if (typeof(InternetExplorerDriver).IsAssignableFrom(driverType))
+ else if (typeof(InternetExplorerDriver).IsAssignableFrom(driverType))
{
browser = Browser.IE;
options = GetDriverOptions<InternetExplorerOptions>(driverType, driverOptions);
service = CreateService<InternetExplorerDriverService>(driverType);
}
-
- if (typeof(EdgeDriver).IsAssignableFrom(driverType))
+ else if (typeof(EdgeDriver).IsAssignableFrom(driverType))
{
browser = Browser.Edge;
options = GetDriverOptions<EdgeOptions>(driverType, driverOptions);
service = CreateService<EdgeDriverService>(driverType);
}
-
- if (typeof(FirefoxDriver).IsAssignableFrom(driverType))
+ else if (typeof(FirefoxDriver).IsAssignableFrom(driverType))
{
browser = Browser.Firefox;
options = GetDriverOptions<FirefoxOptions>(driverType, driverOptions);
service = CreateService<FirefoxDriverService>(driverType);
}
-
- if (typeof(SafariDriver).IsAssignableFrom(driverType))
+ else if (typeof(SafariDriver).IsAssignableFrom(driverType))
{
browser = Browser.Safari;
options = GetDriverOptions<SafariOptions>(driverType, driverOptions);
@@ -112,6 +108,8 @@ public IWebDriver CreateDriverWithOptions(Type driverType, DriverOptions driverO
this.OnDriverLaunching(service, options);
+ if (browser != Browser.All)
+ {
constructorArgTypeList.Add(this.serviceTypes[browser]);
constructorArgTypeList.Add(this.optionsTypes[browser]);
ConstructorInfo ctorInfo = driverType.GetConstructor(constructorArgTypeList.ToArray());
@@ -119,6 +117,7 @@ public IWebDriver CreateDriverWithOptions(Type driverType, DriverOptions driverO
{
return (IWebDriver)ctorInfo.Invoke(new object[] { service, options });
}
+ }
driver = (IWebDriver)Activator.CreateInstance(driverType);
return driver;
