public static void Add(TargetPlatform platform, String path, ICapabilities capabilities) { Type driverType = driverMap[platform]; IWebDriver driver; if (platform.IsWeb()) { DriverOptions options = (DriverOptions)optionsMap[platform].GetConstructor(new Type[] { }).Invoke(new Object[] { }); if (platform == TargetPlatform.FIREFOX) { driver = new FirefoxDriver((FirefoxOptions)options); } else { driver = (IWebDriver)driverType.GetConstructor(new Type[] { typeof(String), optionsMap[platform] }).Invoke(new Object[] { path, options }); } } else { driver = (IWebDriver)driverType.GetConstructor(new Type[] { typeof(Uri), typeof(DesiredCapabilities) }).Invoke(new Object[] { new Uri(path), capabilities }); } String threadName = GetThreadName(); driverThreadMap.Add(threadName, driver); }
public static void Add(TargetPlatform browser, String path, ICapabilities capabilities) { Type driverType = driverMap[browser]; DriverOptions options = null; if (optionsMap.ContainsKey(browser)) { options = (DriverOptions)optionsMap[browser].GetConstructor(new Type[] { }).Invoke(new Object[] { }); } IWebDriver driver; if (browser.IsWeb()) { if (browser == TargetPlatform.FIREFOX) { driver = new FirefoxDriver((FirefoxOptions)options); } else { driver = (IWebDriver)driverType.GetConstructor(new Type[] { typeof(String), optionsMap[browser] }).Invoke(new Object[] { path, options }); } } else { driver = (IWebDriver)driverType.GetConstructor(new Type[] { typeof(Uri), typeof(DesiredCapabilities) }) .Invoke(new Object[] { new Uri(path), capabilities }); } String threadName = GetThreadName(); if (driverThreadMap.ContainsKey(threadName)) { driverThreadMap.Remove(threadName); } driverThreadMap.Add(threadName, driver); }