/// <summary> /// This method will create a local driver, as it takes the LocalDriver configuation object /// </summary> /// <param name="configuration">An instance of the LocalDriverConfiguration object.</param> /// <returns>Driver that mets the configuration</returns> public IWebDriver Create(LocalDriverConfiguration configuration) { //A simple switch statement to determine which driver/service to create. switch (configuration.Browser) { case "chrome": _driver = new ChromeDriver(@"DriverServices"); break; case "internet explorer": var options = new InternetExplorerOptions { EnableNativeEvents = false }; _driver = new InternetExplorerDriver(@"DriverServices", options); break; case "firefox": _driver = new FirefoxDriver(); break; case "phantomjs": _driver = new PhantomJSDriver(@"DriverServices"); break; //If a string isn't matched, it will default to FireFoxDriver default: _driver = new FirefoxDriver(); break; } //Return the driver instance to the calling class. return(_driver); }
/// <summary> /// This method will create a local driver, as it takes the LocalDriver configuation object /// </summary> /// <param name="configuration">An instance of the LocalDriverConfiguration object.</param> /// <returns>Driver that mets the configuration</returns> public IWebDriver Create(LocalDriverConfiguration configuration) { //A simple switch statement to determine which driver/service to create. switch (configuration.Browser.ToLower())//browser Name must lowcase { case "chrome": ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.AddArguments("test-type"); //remove the error information when loading chrome //options.AddArguments("--disable-extensions"); chromeOptions.AddArguments("--no-sandbox"); //solve automation extension crash issue _driver = new ChromeDriver(@"D:\FM\Dev\Gauge\TestKit\TestKit.Web\DriverServices", chromeOptions); break; case "internet explorer": var options = new InternetExplorerOptions { EnableNativeEvents = false }; _driver = new InternetExplorerDriver(@"DriverServices", options); break; case "firefox": _driver = new FirefoxDriver(); break; //case "phantomjs": // _driver = new PhantomJSDriver(@"DriverServices"); // break; //If a string isn't matched, it will default to FireFoxDriver default: _driver = new FirefoxDriver(); break; } //_driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); _driver = GetResolution(configuration.Resolution, _driver); //Return the driver instance to the calling class. return(_driver); }