/// <summary> /// Creates the web driver. /// </summary> /// <param name="browserType">Type of the browser.</param> /// <param name="browserFactoryConfiguration">The browser factory configuration.</param> /// <returns>The created web driver.</returns> /// <exception cref="System.InvalidOperationException">Thrown if the browser is not supported.</exception> internal static IWebDriver CreateWebDriver(BrowserType browserType, BrowserFactoryConfigurationElement browserFactoryConfiguration) { IWebDriver driver; if (!RemoteDriverExists(browserFactoryConfiguration.Settings, browserType, out driver)) { switch (browserType) { case BrowserType.IE: var explorerOptions = new InternetExplorerOptions { EnsureCleanSession = browserFactoryConfiguration.EnsureCleanSession }; var internetExplorerDriverService = InternetExplorerDriverService.CreateDefaultService(); internetExplorerDriverService.HideCommandPromptWindow = true; driver = new InternetExplorerDriver(internetExplorerDriverService, explorerOptions); break; case BrowserType.FireFox: driver = GetFireFoxDriver(browserFactoryConfiguration); break; case BrowserType.Chrome: var chromeOptions = new ChromeOptions { LeaveBrowserRunning = false }; var chromeDriverService = ChromeDriverService.CreateDefaultService(); chromeDriverService.HideCommandPromptWindow = true; driver = new ChromeDriver(chromeDriverService, chromeOptions); break; case BrowserType.PhantomJS: var phantomJsDriverService = PhantomJSDriverService.CreateDefaultService(); phantomJsDriverService.HideCommandPromptWindow = true; driver = new PhantomJSDriver(phantomJsDriverService); break; case BrowserType.Safari: driver = new SafariDriver(); break; default: throw new InvalidOperationException(string.Format("Browser type '{0}' is not supported in Selenium local mode. Did you mean to configure a remote driver?", browserType)); } } // Set Driver Settings var managementSettings = driver.Manage(); // Set timeouts var applicationConfiguration = SpecBind.Helpers.SettingHelper.GetConfigurationSection().Application; managementSettings.Timeouts() .ImplicitlyWait(browserFactoryConfiguration.ElementLocateTimeout) .SetPageLoadTimeout(browserFactoryConfiguration.PageLoadTimeout); ActionBase.DefaultTimeout = browserFactoryConfiguration.ElementLocateTimeout; WaitForPageAction.DefaultTimeout = browserFactoryConfiguration.PageLoadTimeout; ActionBase.RetryValidationUntilTimeout = applicationConfiguration.RetryValidationUntilTimeout; // Maximize window managementSettings.Window.Maximize(); return driver; }
public FakeIEDriver(DriverService service, InternetExplorerOptions options, TimeSpan commandTimeout) { Console.WriteLine("svc opt span2"); this.UnitTestReport = //IEDriverConstructorOptions.ie_with_service_and_options_and_timespan.ToString(); DriverServerConstructorOptions.with_service_and_options_and_timespan.ToString(); }
public static IWebDriver GetConfigBrowser(string browserName) { string AppRoot = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string strDriverPath = null; IWebDriver webDriver = null; if (browserName.Equals("Firefox", StringComparison.InvariantCultureIgnoreCase)) { webDriver = new FirefoxDriver(); } else if (browserName.Equals("chrome", StringComparison.InvariantCultureIgnoreCase)) { strDriverPath = Path.Combine(AppRoot, @"CodedUITests\Drivers\chromedriver_win32"); webDriver = new ChromeDriver(strDriverPath); } else if (browserName.Equals("IE", StringComparison.InvariantCultureIgnoreCase)) { InternetExplorerOptions options = new InternetExplorerOptions() { EnableNativeEvents = true, IgnoreZoomLevel = true }; strDriverPath = Path.Combine(AppRoot, @"CodedUITests\Drivers\IEDriverServer_Win32_2.44.0"); webDriver = new InternetExplorerDriver(strDriverPath, options, TimeSpan.FromMinutes(3.0)); } if (webDriver == null) throw new Exception("must configure browsername in aap.config"); else return webDriver; }
public static RemoteWebDriver getWebDriver(string DriverName = "") { if (WebDriver == null) { switch (DriverName) { case "IE": var options = new InternetExplorerOptions(); options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; WebDriver = new InternetExplorerDriver(/*Settings.CurrentSettings.BrowserPath,*/ options); //IeCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); //WebDriver = new InternetExplorerDriver(ieCapabilities); break; case "CHROME": default: WebDriver = new ChromeDriver(); break; } /*System.setProperty("webdriver.ie.driver", "src\\test\\resources\\drivers\\IEDriverServer.exe"); DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer(); ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); webDriver = new InternetExplorerDriver(ieCapabilities); webDriver.manage().timeouts() .implicitlyWait(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); maximizeBrowser();*/ WebDriver.Manage().Timeouts() .ImplicitlyWait(TimeSpan.FromSeconds(WAIT_TIMEOUT)); MaximizeBrowser(); } return WebDriver; }
//Start the browser depending on the setting public void GetDriver(WebBrowsers webBrws) { WebBrws = webBrws; if (webBrws == WebBrowsers.Ie) { //Secutiry setting for IE var capabilitiesInternet = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true }; Driver = new InternetExplorerDriver(capabilitiesInternet); } else if (webBrws == WebBrowsers.FireFox) { //FirefoxBinary binary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"); FirefoxProfile profile = new FirefoxProfile(); // profile.SetPreference("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); Driver = new FirefoxDriver(profile); } else if (webBrws == WebBrowsers.Chrome) { //Chrome driver requires the ChromeDriver.exe Driver = new ChromeDriver(@"..\..\..\lib\BrowserDriver\Chrome"); } else { throw new WebDriverException(); } Selenium = new WebDriverBackedSelenium(Driver, BaseUrl); }
private static IWebDriver CreateWebDriver() { IWebDriver driver = null; var type = ConfigurationManager.AppSettings["WebDriver"]; switch (type) { case "Firefox": { var profile = new FirefoxProfile { AcceptUntrustedCertificates = true, EnableNativeEvents = true }; driver = new FirefoxDriver(profile); break; } case "InternetExplorer": { // Currently not working var options = new InternetExplorerOptions { IgnoreZoomLevel = true }; driver = new InternetExplorerDriver(options); break; } case "Chrome": default: throw new NotSupportedException(); } return driver; }
/// <summary> /// ‘абричный метод /// </summary> /// <param name="browser"></param> /// <returns></returns> public static RemoteWebDriver GetLocalDriver(string browser) { InternetExplorerOptions internetExplorerOptions; switch (browser) { case "Chrome": return new ChromeDriver(PathToDriver); case "Firefox": var profile = new FirefoxProfile(); //profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", ConfigurationManager.AppSettings["SiteIP"]); return new FirefoxDriver(profile); case "IE": internetExplorerOptions = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true, EnableNativeEvents = true }; return new InternetExplorerDriver( PathToDriver, internetExplorerOptions); default: internetExplorerOptions = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true, EnableNativeEvents = true }; return new InternetExplorerDriver( PathToDriver, internetExplorerOptions); } }
public IWebDriver NewWebDriver(Browser browser) { if (browser == Browser.Firefox) return new FirefoxDriver(); if (browser == Browser.InternetExplorer) { var options = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true, EnableNativeEvents = true }; return new InternetExplorerDriver(options); } if (browser == Browser.Chrome) return new ChromeDriver(); if (browser == Browser.Android) return new AndroidDriver(); if (browser == Browser.HtmlUnit) return new RemoteWebDriver(DesiredCapabilities.HtmlUnit()); if (browser == Browser.HtmlUnitWithJavaScript) { DesiredCapabilities desiredCapabilities = DesiredCapabilities.HtmlUnit(); desiredCapabilities.IsJavaScriptEnabled = true; return new RemoteWebDriver(desiredCapabilities); } if (browser == Browser.PhantomJS) return new PhantomJSDriver(); return browserNotSupported(browser,null); }
public void logging_in_with_invalid_credentials() { var options = new InternetExplorerOptions(); options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; var driver = new InternetExplorerDriver(options); driver.Navigate().GoToUrl(TargetAppUrl + "/Authentication/LogOff"); try { driver.Navigate().GoToUrl(TargetAppUrl + "/LogOn"); driver.FindElement(By.Name("EmailAddress")).SendKeys("*****@*****.**"); driver.FindElement(By.Name("Password")).SendKeys("BadPass"); driver.FindElement(By.TagName("form")).Submit(); driver.Url.ShouldEqual(TargetAppUrl + "/LogOn"); driver.FindElement(By.ClassName("validation-summary-errors")).Text.ShouldContain( "The user name or password provided is incorrect."); } finally { driver.Close(); } }
public IWebDriver Create(LocalDriverConfiguration configuration) { 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; default: _driver = new FirefoxDriver(); break; } return _driver; }
public static IWebDriver GetDriver(DriverType typeOfDriver) { IWebDriver browser; switch (typeOfDriver) { // NOTE REMOTE DRIVER IS NOT SUPPORTED case DriverType.Chrome: ChromeOptions co = new ChromeOptions(); browser = new ChromeDriver(); break; case DriverType.IE: InternetExplorerOptions ieo = new InternetExplorerOptions(); browser = new InternetExplorerDriver(); break; case DriverType.Firefox: default: FirefoxProfile ffp = new FirefoxProfile(); ffp.AcceptUntrustedCertificates = true; ffp.Port = 8181; browser = new FirefoxDriver(ffp); break; } return browser; }
public FakeIEDriver(string internetExplorerDriverServerDirectory, InternetExplorerOptions options) { Console.WriteLine("dir opt2"); this.UnitTestReport = //IEDriverConstructorOptions.ie_with_path_and_options.ToString(); DriverServerConstructorOptions.with_path_and_options.ToString(); }
/// <summary> /// Creates a driver if it has not been created yet. /// </summary> public void SetupDriver() { if (_driver == null) { switch (DriverType) { case DriverTypes.Phantom: _driver = new PhantomJSDriver(DriversPath); break; case DriverTypes.Firefox: _driver = new FirefoxDriver(); break; case DriverTypes.InternetExplorer: var options = new InternetExplorerOptions(); options.IgnoreZoomLevel = true; _driver = new InternetExplorerDriver(DriversPath, options); break; case DriverTypes.Chrome: default: if (!File.Exists("chromedriver.exe")) { _driver = new ChromeDriver(DriversPath); } else _driver = new ChromeDriver(); break; } } }
private static void InitializeWebDriver() { switch (Configuration.BrowserType) { case BrowserType.Firefox: WebDriver = new FirefoxDriver(); break; case BrowserType.InternetExplorer: var ieOptions = new InternetExplorerOptions { EnableNativeEvents = true, EnablePersistentHover = true, EnsureCleanSession = true, UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Dismiss }; WebDriver = new InternetExplorerDriver("./", ieOptions); break; case BrowserType.Chrome: var chromeOptions = new ChromeOptions(); chromeOptions.AddArguments("test-type"); WebDriver = new ChromeDriver("./", chromeOptions); break; default: throw new ArgumentException("Unknown browser type is specified!"); } WebDriver.Manage().Window.Maximize(); WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(Configuration.ImplicitWaitTime)); }
public FakeIEDriver(InternetExplorerOptions options) { Console.WriteLine("opt2"); this.UnitTestReport = //IEDriverConstructorOptions.ie_with_options.ToString(); DriverServerConstructorOptions.with_options.ToString(); }
/// <summary> /// Performs the initialize of the browser. /// </summary> /// <param name="driverFolder">The driver folder.</param> /// <param name="proxy">The proxy.</param> /// <returns> /// The web driver. /// </returns> protected override IWebDriver PerformInitialize(string driverFolder, Proxy proxy) { var options = new InternetExplorerOptions(); options.Proxy = proxy; options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; return new InternetExplorerDriver(driverFolder, options); }
/// <summary> /// Starts the specified browser. /// </summary> /// <param name="browser">The browser.</param> /// <exception cref="System.NotSupportedException">When driver not supported</exception> public void Start(string browser) { switch (browser) { case "Firefox": Handle = new FirefoxDriver(this.FirefoxProfile); break; case "FirefoxPortable": var profile = this.FirefoxProfile; var firefoxBinary = new FirefoxBinary(BaseConfiguration.FirefoxPath); Handle = new FirefoxDriver(firefoxBinary, profile); break; case "InternetExplorer": var options = new InternetExplorerOptions { EnsureCleanSession = true, }; Handle = new InternetExplorerDriver(@"Drivers\", options); break; case "Chrome": Handle = new ChromeDriver(@"Drivers\"); break; default: throw new NotSupportedException( string.Format(CultureInfo.CurrentCulture, "Driver {0} is not supported", browser)); } Handle.Manage().Window.Maximize(); }
/// <summary> /// Initializes a new instance of the <see cref="Driver"/> class. /// </summary> /// <param name="browser">Browser name.</param> /// <param name="timeout">Implicit time to wait.</param> public Driver(string browser, int timeout = 10) { this.timeout = timeout; Log.Debug("Working directory: " + this.directory); Log.Debug("Browser: " + browser); Log.Debug("Driver timeout: " + timeout); switch (browser) { case "firefox": this.driver = new FirefoxDriver(); break; case "ie": var ieOptions = new InternetExplorerOptions { EnsureCleanSession = true }; this.driver = new InternetExplorerDriver(this.directory, ieOptions); break; case "edge": this.driver = new EdgeDriver(this.directory); break; case "chrome": this.driver = new ChromeDriver(this.directory); break; case "safari": this.driver = new SafariDriver(); break; default: throw new Exception("Browser name is incorrect."); } this.driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, timeout)); this.driver.Manage().Cookies.DeleteAllCookies(); this.driver.Manage().Window.Maximize(); }
public void InitDriver() { if (!Directory.Exists(@"P:\LabsDeploymentItems")) throw new Exception(@"Unable to locate P:\LabsDeploymentItems"); switch (Properties.Settings.Default.BROWSER) { case BrowserType.Chrome: WebDriver = new ChromeDriver(driversLocation); break; case BrowserType.Ie: InternetExplorerOptions opts = new InternetExplorerOptions(); opts.EnsureCleanSession = true; opts.IntroduceInstabilityByIgnoringProtectedModeSettings = true; WebDriver = new InternetExplorerDriver(driversLocation, opts); break; case BrowserType.Firefox: WebDriver = new FirefoxDriver(); break; default: throw new ArgumentException("Invalid BROWSER Setting has been used"); } WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(Properties.Settings.Default.IMPLICIT_WAIT_SECONDS)); WebDriver.Manage().Window.Maximize(); }
private static InternetExplorerOptions GetIEOptions() { InternetExplorerOptions options = new InternetExplorerOptions(); options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; options.EnsureCleanSession = true; options.ElementScrollBehavior = InternetExplorerElementScrollBehavior.Bottom; return options; }
public void TestHappyPathInternetExplorer() { InternetExplorerOptions options = new InternetExplorerOptions(); options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; InternetExplorerDriver ied = new InternetExplorerDriver(options); TestHappyPath(ied); }
private InternetExplorerDriver CreateInternetExplorerDriver() { var options = new InternetExplorerOptions() { IgnoreZoomLevel = true }; return new InternetExplorerDriver(options); }
public static IWebDriver getIEDriver() { DriverFactory.DeleteIECookiesAndData(); InternetExplorerOptions options = new InternetExplorerOptions(); options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; IWebDriver driver = new InternetExplorerDriver(options); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(waitsec)); return driver; }
public void BeforeScenario() { var internetExplorerOptions = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true }; var driver = new InternetExplorerDriver(internetExplorerOptions); ScenarioContext.Current.Set(driver, "WebDriver"); }
private static InternetExplorerDriver InternetExplorer(InternetExplorerOptions options = null) { if (options == null) { options = new InternetExplorerOptions(); options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; } return new InternetExplorerDriver(options); }
// private const string IE_DRIVER_PATH = @"D:\selenium-dotnet-2.33.0"; public void SetupTest() { var options = new InternetExplorerOptions(); options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; //driver = new InternetExplorerDriver(IE_DRIVER_PATH, options); driver = new InternetExplorerDriver(options); baseURL = "http://qa.englishtown.com/partner/coolschool/Default.aspx"; verificationErrors = new StringBuilder(); }
/// <summary> /// Gets a driver of perticular type. /// </summary> /// <param name="driverType">Type of the driver</param> /// <param name="testCaseName">The TC requesting the driver</param> /// <returns></returns> public IWebDriver GetDriver(string testCaseName) { switch (ConfigurationSettings.AppSettings["TargetDriver"].ToString()) { case "IE": { var options = new InternetExplorerOptions(); options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; options.IgnoreZoomLevel = true; IWebDriver driver = new InternetExplorerDriver(ConfigurationSettings.AppSettings["IEDriverServerPath"].ToString(),options); InitializeDriverOperations(driver); //For Grid //System.Environment.SetEnvironmentVariable("webdriver.ie.driver", ConfigurationSettings.AppSettings["IEDriverServerPath"].ToString() +"\\IEDriverServer.exe"); //DesiredCapabilities capability = DesiredCapabilities.InternetExplorer(); //IWebDriver driver = new ScreenShotRemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability); DriverSessions.AddSession(testCaseName, driver); return driver; } case "Firefox": { IWebDriver driver = new FirefoxDriver(); InitializeDriverOperations(driver); //For Grid //DesiredCapabilities capability = DesiredCapabilities.Firefox(); //IWebDriver driver = new ScreenShotRemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability); DriverSessions.AddSession(testCaseName, driver); return driver; } case "Chrome": { IWebDriver driver = new ChromeDriver(ConfigurationSettings.AppSettings["ChromeDriverServerPath"].ToString()); InitializeDriverOperations(driver); //For Grid //System.Environment.SetEnvironmentVariable("webdriver.ie.driver", ConfigurationSettings.AppSettings["IEDriverServerPath"].ToString() +"\\IEDriverServer.exe"); //DesiredCapabilities capability = DesiredCapabilities.Chrome(); //IWebDriver driver = new ScreenShotRemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability); DriverSessions.AddSession(testCaseName, driver); return driver; } default: return null; } }
public IWebDriver StartBrowser() { Common.WebBrowser = System.Configuration.ConfigurationSettings.AppSettings["Browser"].ToLower(); string driverDir = System.Configuration.ConfigurationSettings.AppSettings["DriverDir"]; string driverPath = ""; switch (Common.WebBrowser.ToLower()) { case "firefox": _cap = DesiredCapabilities.Firefox(); _cap.SetCapability(CapabilityType.AcceptSslCertificates, true); _ffp = new FirefoxProfile(); _ffp.AcceptUntrustedCertificates = true; _driver = new FirefoxDriver(_ffp); break; case "iexplore": _cap = DesiredCapabilities.InternetExplorer(); _cap.SetCapability(CapabilityType.AcceptSslCertificates, true); _ie = new InternetExplorerOptions(); _ie.IgnoreZoomLevel = true; _ie.IntroduceInstabilityByIgnoringProtectedModeSettings = true; switch (OS.IsOS64Bit()) { case true: Console.WriteLine("Running the test on 64 bit Operating System."); driverPath = driverDir + "\\x64_IE_driver"; Console.WriteLine("test"); Common.OSbit = 64; break; case false: Console.WriteLine("Running the test on 32 bit Operating System."); driverPath = driverDir + "\\Win32_IE_driver"; Common.OSbit = 32; break; } _driver = new InternetExplorerDriver(driverPath, _ie, Common.DriverTimeout); break; case "chrome": driverPath = driverDir + "\\Chrome"; _cap = DesiredCapabilities.Chrome(); _cap.SetCapability(CapabilityType.AcceptSslCertificates, true); _chrome = new ChromeOptions(); //_chrome.AddArgument("--new-window"); //_chrome.AddArguments("-user-data-dir=c:\\chrome --new-window %1"); _driver = new ChromeDriver(driverPath, _chrome, Common.DriverTimeout); break; } _driver.Manage().Cookies.DeleteAllCookies(); _driver.Manage().Window.Maximize(); //navigateToApplication(); return _driver; }
private static IWebDriver CreateNewWebDriver(string webBrowserName, BrowserType type, out IntPtr mainWindowHandle, string driversDirectory) { webBrowserName = webBrowserName.ToLower(); IWebDriver iWebDriver = null; List <Process> processesBeforeLaunch = GetProcesses(); string newProcessFilter = string.Empty; switch (type) { case BrowserType.Chrome: var chromeService = Chrome.ChromeDriverService.CreateDefaultService(driversDirectory); chromeService.HideCommandPromptWindow = true; var chromeOptions = new Chrome.ChromeOptions(); chromeOptions.PageLoadStrategy = PageLoadStrategy.None; chromeOptions.AddArgument("disable-infobars"); chromeOptions.AddArgument("--disable-bundled-ppapi-flash"); chromeOptions.AddArgument("--log-level=3"); chromeOptions.AddArgument("--silent"); chromeOptions.AddUserProfilePreference("credentials_enable_service", false); chromeOptions.AddUserProfilePreference("profile.password_manager_enabled", false); chromeOptions.AddUserProfilePreference("auto-open-devtools-for-tabs", false); //chromeOptions.AddAdditionalCapability("pageLoadStrategy", "none", true); iWebDriver = new Chrome.ChromeDriver(chromeService, chromeOptions); newProcessFilter = "chrome"; break; case BrowserType.Firefox: var firefoxService = Firefox.FirefoxDriverService.CreateDefaultService(driversDirectory); firefoxService.HideCommandPromptWindow = true; iWebDriver = new Firefox.FirefoxDriver(firefoxService); newProcessFilter = "firefox"; break; case BrowserType.InternetExplorer: IE.InternetExplorerDriverService ieService = IE.InternetExplorerDriverService.CreateDefaultService(driversDirectory); ieService.HideCommandPromptWindow = true; IE.InternetExplorerOptions options = new IE.InternetExplorerOptions() { IgnoreZoomLevel = true }; iWebDriver = new IE.InternetExplorerDriver(ieService, options); newProcessFilter = "iexplore"; break; case BrowserType.Edge: var edgeService = Edge.EdgeDriverService.CreateDefaultService(driversDirectory); edgeService.HideCommandPromptWindow = true; var edgeOptions = new Edge.EdgeOptions(); edgeOptions.PageLoadStrategy = PageLoadStrategy.Eager; iWebDriver = new Edge.EdgeDriver(edgeService, edgeOptions); newProcessFilter = "edge"; break; default: throw new ArgumentException($"Could not launch specified browser '{webBrowserName}'"); } var newProcess = GetNewlyCreatedProcesses(newProcessFilter, processesBeforeLaunch); mainWindowHandle = (newProcess != null) ? newProcess.MainWindowHandle : IntPtr.Zero; return(iWebDriver); }
public EdgeInternetExplorerModeDriver(InternetExplorerDriverService service, InternetExplorerOptions options) : base(service, options) { }
private QA.IWebDriver InitWebDriver() { QA.IWebDriver theDriver = null; switch (this.browser) { case Browsers.IE: { InternetExplorerDriverService driverService = InternetExplorerDriverService.CreateDefaultService(Application.StartupPath + "\\drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; QA.IE.InternetExplorerOptions _ieOptions = new QA.IE.InternetExplorerOptions(); _ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings = true; theDriver = new QA.IE.InternetExplorerDriver(driverService, _ieOptions); ProcessID = driverService.ProcessId; }; break; case Browsers.PhantomJS: { PhantomJSDriverService driverService = PhantomJSDriverService.CreateDefaultService(Application.StartupPath + "\\Drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; theDriver = new QA.PhantomJS.PhantomJSDriver(driverService); }; break; case Browsers.Chrome: { ChromeDriverService driverService = ChromeDriverService.CreateDefaultService(Application.StartupPath + "\\drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; ChromeOptions options = new QA.Chrome.ChromeOptions(); options.AddUserProfilePreference("profile.managed_default_content_settings.images", _IsLoadPicture ? 1 : 2); options.AddUserProfilePreference("profile.managed_default_content_settings.javascript", _IsLoadJS ? 1 : 2); //options.AddArgument(@"--user-data-dir=" + cache_dir); //string dir = string.Format(@"user-data-dir={0}", ConfigManager.GetInstance().UserDataDir); //options.AddArguments(dir); //options.AddArgument("--no-sandbox"); //options.AddArgument("--disable-dev-shm-usage"); //options.AddArguments("--disable-extensions"); // to disable extension //options.AddArguments("--disable-notifications"); // to disable notification //options.AddArguments("--disable-application-cache"); // to disable cache try { if (_timeout == 60) { theDriver = new QA.Chrome.ChromeDriver(driverService, options, new TimeSpan(0, 0, 40)); } else { theDriver = new QA.Chrome.ChromeDriver(driverService, options, new TimeSpan(0, 0, _timeout)); } } catch (Exception ex) { } ProcessID = driverService.ProcessId; }; break; case Browsers.Firefox: { var driverService = FirefoxDriverService.CreateDefaultService(Application.StartupPath + "\\drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; FirefoxProfile profile = new FirefoxProfile(); try { if (_doproxy == "1") { string proxy = ""; try { if (_IsUseNewProxy == false) { proxy = GetProxyA(); } else { //TO DO 获取芝麻代理 hi.URL = "http:......?你的代理地址"; // ConfigManager.GetInstance().ProxyUrl; hr = hh.GetContent(hi); if (hr.StatusCode == System.Net.HttpStatusCode.OK) { if (hr.Content.Contains("您的套餐余量为0")) { proxy = ""; } if (hr.Content.Contains("success") == false) { proxy = ""; } JObject j = JObject.Parse(hr.Content); foreach (var item in j) { foreach (var itemA in item.Value) { if (itemA.ToString().Contains("expire_time")) { if (DateTime.Now.AddHours(2) < DateTime.Parse(itemA["expire_time"].ToString())) { proxy = itemA["ip"].ToString() + ":" + itemA["port"].ToString(); break; } } } if (proxy != "") { break; } } } } } catch (Exception ex) { } if (proxy != "" && proxy.Contains(":")) { OpenQA.Selenium.Proxy proxyF = new OpenQA.Selenium.Proxy(); proxyF.HttpProxy = proxy; proxyF.FtpProxy = proxy; proxyF.SslProxy = proxy; profile.SetProxyPreferences(proxyF); // 使用代理 profile.SetPreference("network.proxy.type", 1); //ProxyUser-通行证书 ProxyPass-通行密钥 profile.SetPreference("username", "你的账号"); profile.SetPreference("password", "你的密码"); // 所有协议公用一种代理配置,如果单独配置,这项设置为false profile.SetPreference("network.proxy.share_proxy_settings", true); // 对于localhost的不用代理,这里必须要配置,否则无法和webdriver通讯 profile.SetPreference("network.proxy.no_proxies_on", "localhost"); } } } catch (Exception ex) { } //profile.SetPreference("permissions.default.image", 2); // 关掉flash profile.SetPreference("dom.ipc.plugins.enabled.libflashplayer.so", false); FirefoxOptions options = new FirefoxOptions(); options.Profile = profile; theDriver = new QA.Firefox.FirefoxDriver(driverService, options, TimeSpan.FromMinutes(1)); ProcessID = driverService.ProcessId; }; break; case Browsers.Safari: { SafariDriverService driverService = SafariDriverService.CreateDefaultService(Application.StartupPath + "\\Drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; theDriver = new QA.Safari.SafariDriver(driverService); ProcessID = driverService.ProcessId; }; break; default: { QA.IE.InternetExplorerOptions _ieOptions = new QA.IE.InternetExplorerOptions(); _ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings = true; theDriver = new QA.IE.InternetExplorerDriver(_ieOptions); }; break; } return(theDriver); }
/// <summary> /// Initializes a new instance of the InternetExplorerDriver class using the specified path to the directory containing IEDriverServer.exe and command timeout. /// </summary> /// <param name="internetExplorerDriverServerDirectory">The full path to the directory containing IEDriverServer.exe.</param> /// <param name="options">The <see cref="InternetExplorerOptions"/> used to initialize the driver.</param> public InternetExplorerDriver(string internetExplorerDriverServerDirectory, InternetExplorerOptions options) : this(internetExplorerDriverServerDirectory, options, TimeSpan.FromSeconds(60)) { }
/// <summary> /// Initializes a new instance of the <see cref="InternetExplorerDriver"/> class using the specified /// <see cref="DriverService"/>, <see cref="InternetExplorerOptions"/>, and command timeout. /// </summary> /// <param name="service">The <see cref="InternetExplorerDriverService"/> to use.</param> /// <param name="options">The <see cref="InternetExplorerOptions"/> used to initialize the driver.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public InternetExplorerDriver(InternetExplorerDriverService service, InternetExplorerOptions options, TimeSpan commandTimeout) : base(new DriverServiceCommandExecutor(service, commandTimeout), ConvertOptionsToCapabilities(options)) { }
/// <summary> /// Initializes a new instance of the InternetExplorerDriver class with the desired options. /// </summary> /// <param name="options">The <see cref="InternetExplorerOptions"/> used to initialize the driver.</param> public InternetExplorerDriver(InternetExplorerOptions options) : this(InternetExplorerDriverService.CreateDefaultService(), options, TimeSpan.FromSeconds(60)) { }
/// <summary> /// Initializes a new instance of the <see cref="InternetExplorerDriver"/> class with the desired /// options. /// </summary> /// <param name="options">The <see cref="InternetExplorerOptions"/> used to initialize the driver.</param> public InternetExplorerDriver(InternetExplorerOptions options) : this(InternetExplorerDriverService.CreateDefaultService(), options) { }
/// <summary> /// Initializes a new instance of the <see cref="InternetExplorerDriver"/> class using the specified /// <see cref="InternetExplorerDriverService"/> and options. /// </summary> /// <param name="service">The <see cref="DriverService"/> to use.</param> /// <param name="options">The <see cref="InternetExplorerOptions"/> used to initialize the driver.</param> public InternetExplorerDriver(InternetExplorerDriverService service, InternetExplorerOptions options) : this(service, options, RemoteWebDriver.DefaultCommandTimeout) { }
/// <summary> /// Initializes a new instance of the <see cref="InternetExplorerDriver"/> class using the specified path /// to the directory containing IEDriverServer.exe, options, and command timeout. /// </summary> /// <param name="internetExplorerDriverServerDirectory">The full path to the directory containing IEDriverServer.exe.</param> /// <param name="options">The <see cref="InternetExplorerOptions"/> used to initialize the driver.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public InternetExplorerDriver(string internetExplorerDriverServerDirectory, InternetExplorerOptions options, TimeSpan commandTimeout) : this(InternetExplorerDriverService.CreateDefaultService(internetExplorerDriverServerDirectory), options, commandTimeout) { }
/// <summary> /// Initializes a new instance of the <see cref="InternetExplorerDriver"/> class using the specified path /// to the directory containing IEDriverServer.exe and options. /// </summary> /// <param name="internetExplorerDriverServerDirectory">The full path to the directory containing IEDriverServer.exe.</param> /// <param name="options">The <see cref="InternetExplorerOptions"/> used to initialize the driver.</param> public InternetExplorerDriver(string internetExplorerDriverServerDirectory, InternetExplorerOptions options) : this(internetExplorerDriverServerDirectory, options, RemoteWebDriver.DefaultCommandTimeout) { }
/// <summary> /// Initializes a new instance of the <see cref="InternetExplorerDriver"/> class using the specified path /// to the directory containing IEDriverServer.exe and options. /// </summary> /// <param name="internetExplorerDriverServerDirectory">The full path to the directory containing IEDriverServer.exe.</param> /// <param name="options">The <see cref="InternetExplorerOptions"/> used to initialize the driver.</param> public InternetExplorerDriver(string internetExplorerDriverServerDirectory, InternetExplorerOptions options) : this(InternetExplorerDriverService.CreateDefaultService(internetExplorerDriverServerDirectory), options) { }
public WindowFocusInternetExplorerDriver(InternetExplorerDriverService service, InternetExplorerOptions options) : base(service, options) { }
public FakeIEDriver(string internetExplorerDriverServerDirectory, InternetExplorerOptions options, TimeSpan commandTimeout) { Console.WriteLine("dir opt span2"); this.UnitTestReport = //IEDriverConstructorOptions.ie_with_path_and_options_and_timespan.ToString(); DriverServerConstructorOptions.with_path_and_options_and_timespan.ToString(); }
public static IWebDriver Create(string browser) { DesiredCapabilities capabilities; IWebDriver driver; switch (browser) { case "chrome": capabilities = DesiredCapabilities.Chrome(); driver = new RemoteWebDriver(remoteWebDriverUri, capabilities); break; case "internet explorer": InternetExplorerOptions options = new InternetExplorerOptions(); options.IgnoreZoomLevel = true; capabilities = (DesiredCapabilities)options.ToCapabilities(); driver = new RemoteWebDriver(remoteWebDriverUri, capabilities, TimeSpan.FromSeconds(10)); break; case "edge": capabilities = DesiredCapabilities.Edge(); driver = new RemoteWebDriver(remoteWebDriverUri, capabilities); break; default: capabilities = DesiredCapabilities.Firefox(); driver = new RemoteWebDriver(remoteWebDriverUri, capabilities); break; } return driver; }