/// <summary> /// returns an Internet Explorer driver /// </summary> /// <returns></returns> private IWebDriver GetInternetExplorerDriver() { Console.Write("Loading IE Driver"); IWebDriver d; if (Settings.isLocal) { /* * If you can't get the IE driver to work, open IE and select * Tools > Internet Options (switch to the "security" tab) * check "Enable Protected Mode (requires restarting Internet Explorer) */ InternetExplorerOptions options = new InternetExplorerOptions(); options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; d = new InternetExplorerDriver(URL.driver, options); } else { DesiredCapabilities capabilities = DesiredCapabilities.InternetExplorer(); capabilities.SetCapability(CapabilityType.AcceptSslCertificates, true); capabilities.SetCapability(CapabilityType.HandlesAlerts, true); capabilities.SetCapability("ignoreProtectedModeSettings", true); d = new RemoteWebDriverPlus(new Uri(URL.seleniumHub), capabilities); } d.Manage().Cookies.DeleteAllCookies(); return(d); }
/// <summary> /// returns a Chrome driver /// </summary> /// <returns></returns> private IWebDriver GetChromeDriver() { Console.Write("Loading Chrome Driver"); IWebDriver d; ChromeOptions options = setStandardChromeOptions(); if (Settings.isLocal) { d = new ChromeDriver(URL.driver, options); Console.WriteLine(", Chrome Version: " + getDriverVersion(d)); return(d); } //if not local, then connect through the hub int connectionLimit = 3; DesiredCapabilities capability = (DesiredCapabilities)options.ToCapabilities(); for (int connectionAttempts = 0; connectionAttempts < connectionLimit; connectionAttempts++) { Console.Write("-> Connection Attempt: " + (connectionAttempts + 1)); try { if (UseDevSeleniumHub) { Console.WriteLine(" Running against the devSeleniumHub"); var uri = new Uri(URL.devSeleniumHub); d = new RemoteWebDriverPlus(uri, capability, TimeSpan.FromSeconds(120)); } else { Console.WriteLine(" Running against the SeleniumHub"); d = new RemoteWebDriverPlus(new Uri(URL.seleniumHub), capability, TimeSpan.FromSeconds(120)); } Console.WriteLine("-> Connection established"); Console.WriteLine("Chrome Version: " + getDriverVersion(d)); return(d); } catch (Exception e) { Console.WriteLine(" -> Error thrown. Retrying."); Thread.Sleep(2500); if (connectionAttempts == connectionLimit - 1) { Console.WriteLine("-> Connection Failed"); Console.WriteLine("Error: " + e.Message); } } } return(null); }
private IWebDriver GetEdgeDriver() { IWebDriver d; if (Settings.isLocal) { EdgeOptions options = new EdgeOptions(); d = new EdgeDriver(URL.driver, options); return(d); } else { DesiredCapabilities capabilities = DesiredCapabilities.Edge(); var uri = new Uri(URL.devSeleniumHub); d = new RemoteWebDriverPlus(uri, capabilities, TimeSpan.FromSeconds(120)); return(d); } }
/// <summary> /// TODO: Set as Private /// </summary> /// <param name="locale"></param> /// <returns></returns> public IWebDriver GetFirefoxDriver(string locale = "", FirefoxProfile profile = null) { Console.Write("Loading FireFox Driver"); if (locale == "") { locale = "en_US"; } IWebDriver d; if (profile == null) { profile = new FirefoxProfile(); profile.AcceptUntrustedCertificates = true; profile.AssumeUntrustedCertificateIssuer = true; } if (Settings.isLocal) { FirefoxOptions options = new FirefoxOptions(); options.Profile = profile; options.AddAdditionalCapability(CapabilityType.AcceptSslCertificates, true); options.AddAdditionalCapability(CapabilityType.HasNativeEvents, true); options.AddAdditionalCapability("acceptSslCerts", true); options.AddAdditionalCapability("acceptInsecureCerts", true); options.SetLoggingPreference(LogType.Browser.ToString(), LogLevel.All); options.LogLevel = FirefoxDriverLogLevel.Trace; FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(URL.driver); d = new FirefoxDriver(service, options, TimeSpan.FromMinutes(60)); return(d); } else { DesiredCapabilities desiredCapabilities = DesiredCapabilities.Firefox(); desiredCapabilities.SetCapability("firefox_profile", profile); d = new RemoteWebDriverPlus(new Uri(URL.seleniumHub), desiredCapabilities); return(d); } }