/// <summary> /// Method to get Internet Explorer drivers /// </summary> /// <returns></returns> public static IWebDriver GetInternetExplorerDriver() { KillProcessByName("IExplore"); KillProcessByName("IEDriverServer"); var options = new InternetExplorerOptions { RequireWindowFocus = false, EnableNativeEvents = false, IgnoreZoomLevel = true, //UnhandledPromptBehavior.Accept; //InternetExplorerUnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Accept, IntroduceInstabilityByIgnoringProtectedModeSettings = true }; options.AddAdditionalCapability("disable-popup-blocking", true); TimeSpan timeout = new TimeSpan(1200000000); var driverService = InternetExplorerDriverService.CreateDefaultService(Config.SolutionPath + @"\packages\Selenium.WebDriver.IEDriver.3.11.1\driver\"); driverService.HideCommandPromptWindow = true; Utils.driver = new InternetExplorerDriver(driverService, options, timeout); return(Utils.driver); }
/// <summary> /// The initialize web driver internet explorer. /// </summary> /// <returns> /// The <see cref="bool"/>. /// </returns> private bool InitializeWebDriverInternetExplorer() { var retVal = true; var driverOptions = GetInternetExplorerOptions(); try { var driverService = InternetExplorerDriverService.CreateDefaultService(Configuration.DriverServerPath); driverService.LogFile = DriverLogFile; driverService.LoggingLevel = GetDriverLoggingLevel(); WebDriver = new InternetExplorerDriver( driverService, driverOptions, TimeSpan.FromSeconds(Configuration.BrowserTimeout)); WebDriver.Manage().Window.Maximize(); ResetImplicitlyWait(); } catch (Exception ex) { StfLogger.LogInternal($"Couldn't Initialize WebAdapter - got error [{ex.Message}]"); retVal = false; } StfLogger.LogDebug("Done initializing {0}. Successful: {1}", GetType().Name, retVal.ToString()); return(retVal); }
/// <summary> /// The set up internet explorer web driver. /// </summary> public static void SetUpInternetExplorerWebDriver() { WebDriver = new InternetExplorerDriver(InternetExplorerDriverService.CreateDefaultService(WebDriverPath), new InternetExplorerOptions(), TimeSpan.FromSeconds(10)); WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); WebDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(5)); WebDriver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(5)); }
//Start WebDriver public static IWebDriver opendriver(Browser browser) { Console.WriteLine("Opening seleniumdriver"); driver = null; switch (browser) { case Browser.Firefox: FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(); service.FirefoxBinaryPath = @"C:\Program Files\Mozilla Firefox\firefox.exe"; FirefoxDriver webDriver = new FirefoxDriver(service); break; case Browser.Chrome: driver = new ChromeDriver(); driver.Manage().Window.Maximize(); break; case Browser.IE: InternetExplorerDriverService ieservice = InternetExplorerDriverService.CreateDefaultService(); ieservice.SuppressInitialDiagnosticInformation = true; var options = new InternetExplorerOptions(); options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; driver = new InternetExplorerDriver(ieservice, options); driver.Manage().Window.Maximize(); break; } if (driver != null) { driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(200); } return(driver); }
public override IWebDriver CreateLocalDriver() { InternetExplorerDriverService service; if (IEDriverServer != null) { service = InternetExplorerDriverService.CreateDefaultService(IEDriverServer); } else { string path = Environment.GetEnvironmentVariable("webdriver.ie.driver", EnvironmentVariableTarget.Machine); if (path != null) { service = InternetExplorerDriverService.CreateDefaultService(path); } else { service = InternetExplorerDriverService.CreateDefaultService(); } } var driver = new InternetExplorerDriver(service, GetOptions(), TimeSpan.FromSeconds(Timeouts.HttpCommandTimeout)); ProcessID = service.ProcessId; return(driver); }
/// <summary> /// Gets the capabilities for IE /// </summary> /// <param name="acceptSlefSignedSSL"></param> /// <param name="_ignoreZoomLevel"></param> /// <param name="_enableNativeEvents"></param> /// <param name="_ensureCleanSession"></param> /// <param name="browserTimeoutMilloseconds"></param> /// <param name="_scrollBehaviour"></param> /// <param name="_promtBehaviour"></param> /// <param name="_loadStrategy"></param> /// <returns></returns> private InternetExplorerOptions GetIEBrowserOptions( bool acceptSlefSignedSSL = false, bool _ignoreZoomLevel = true, bool _enableNativeEvents = false, bool _ensureCleanSession = false, int browserTimeoutMilloseconds = 300000, InternetExplorerElementScrollBehavior _scrollBehaviour = InternetExplorerElementScrollBehavior.Default, UnhandledPromptBehavior _promtBehaviour = UnhandledPromptBehavior.Default, PageLoadStrategy _loadStrategy = PageLoadStrategy.Eager) { IEService = InternetExplorerDriverService.CreateDefaultService(Directory.GetCurrentDirectory(), @"IEDriverServer.exe"); IEService.LoggingLevel = InternetExplorerDriverLogLevel.Trace; IEService.HideCommandPromptWindow = false; IEService.Start(); return(new InternetExplorerOptions() { ElementScrollBehavior = _scrollBehaviour, EnableNativeEvents = _enableNativeEvents, IgnoreZoomLevel = _ignoreZoomLevel, ForceCreateProcessApi = false, ForceShellWindowsApi = true, EnablePersistentHover = true, FileUploadDialogTimeout = new TimeSpan(0, 0, 0, browserTimeoutMilloseconds), RequireWindowFocus = true, UnhandledPromptBehavior = _promtBehaviour, BrowserAttachTimeout = new TimeSpan(0, 0, 0, browserTimeoutMilloseconds), EnsureCleanSession = _ensureCleanSession, PageLoadStrategy = _loadStrategy, AcceptInsecureCertificates = acceptSlefSignedSSL }); }
public static IWebDriver CreateWindow(BrowserType browserType = BrowserType.Chrome, bool isAutoLogin = false) { IWebDriver driver = null; switch (browserType) { case BrowserType.Chrome: { var driverService = ChromeDriverService.CreateDefaultService(DriverPathOfChrome); var chromeOptions = new ChromeOptions(); driverService.Port = 8777; driver = new ChromeDriver(driverService, chromeOptions, TimeSpan.FromMinutes(5)); } break; case BrowserType.IE: { var driverService = InternetExplorerDriverService.CreateDefaultService(DriverPathOfIE_32Bit); //DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); //capabilities.set(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, //true); //WebDriver driver = new InternetExplorerDriver(capabilities); var ieOptions = new InternetExplorerOptions(); ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings = true; driver = new InternetExplorerDriver(driverService, ieOptions); } break; } return(driver); }
/*public void executandoThread() { * * ThreadStart ts = new ThreadStart(InicializaValores); * CrossThreadTestRunner runner = new CrossThreadTestRunner(ts); * runner.Run(); * } */ /* public TestBase_Vendas() { * driver = ObtemDriver(); * }*/ protected virtual IWebDriver ObtemDriver(TipoDriver tipoDriver) { switch (tipoDriver) { case TipoDriver.Chrome: { var chromeDriverService = ChromeDriverService.CreateDefaultService(); chromeDriverService.HideCommandPromptWindow = true; ChromeOptions chromeOptions = new ChromeOptions(); //chromeOptions.AddArguments("headless"); chromeOptions.AddArguments("--incognito"); chromeOptions.AddArgument("--window-size=1300,1000"); driver = new ChromeDriver(chromeDriverService, chromeOptions, TimeSpan.FromSeconds(60)); break; } case TipoDriver.Firefox: { driver = new FirefoxDriver(); break; } case TipoDriver.InternetExplorer: { var IEservice = InternetExplorerDriverService.CreateDefaultService(); IEservice.HideCommandPromptWindow = true; IEservice.SuppressInitialDiagnosticInformation = true; InternetExplorerOptions IEoptions = new InternetExplorerOptions(); IEoptions.EnsureCleanSession = true; IEoptions.BrowserCommandLineArguments = "-private"; driver = new InternetExplorerDriver(IEoptions); break; } } return(driver); }
public static IWebDriver GetDriver(BrowserType browserType) { IWebDriver driver; switch (browserType) { case BrowserType.Chrome: { var options = new ChromeOptions(); var service = ChromeDriverService.CreateDefaultService(); driver = new ChromeDriver(service, options); break; } case BrowserType.IE: { var options = new InternetExplorerOptions(); var service = InternetExplorerDriverService.CreateDefaultService(); driver = new InternetExplorerDriver(service, options); break; } default: { throw new ArgumentException("Your browser is not supported"); // excpб если какой-то другой браузер будет } } return(driver); }
private void selectBrowser(string browser) { switch (browser) { case "Chrome": { driver = new ChromeDriver(chromeDriverService, cOptions); } break; case "FireFox": { var driverService = FirefoxDriverService.CreateDefaultService(); driverService.HideCommandPromptWindow = true; driver = new FirefoxDriver(driverService); } break; case "IE": { var driverService = InternetExplorerDriverService.CreateDefaultService(); driverService.HideCommandPromptWindow = true; driver = new InternetExplorerDriver(driverService); } break; case "랜덤": { string[] browsers = { "Chrome", "FireFox", "IE" }; selectBrowser(browsers[CommonUtils.GetRandomValue(0, browsers.Length - 1)]); } break; } }
// Schreibt die Aufrufe von Trace nach Console.Out und somit in das Resharper Output-Window! //private static TraceListener _listener; public static void InitTests(TestContext testContext) { if (App != null) { return; } Trace.Listeners.Add(new ConsoleTraceListener()); testContext.WriteLine($"Test initialized '{testContext.TestName}'."); testContext.WriteLine("Instantiation of WebDriver ... "); WebsiteBaseUrl = ConfigurationManager.AppSettings["WebsiteBaseUrl"]; _browserType = ConfigurationManager.AppSettings["BrowserType"]; var timeOutStr = ConfigurationManager.AppSettings["DefaultTimeOutInSeconds"] ?? "4"; var timeOut = int.Parse(timeOutStr); try { switch (_browserType.ToLower()) { case "ie": var service = InternetExplorerDriverService.CreateDefaultService(); service.SuppressInitialDiagnosticInformation = true; Driver = new InternetExplorerDriver(service); break; case "firefox": Driver = new FirefoxDriver(); break; case "chrome": Driver = new ChromeDriver(); break; } } catch (Exception ex) { Trace.WriteLine("Instantiation of WebDriver failed: " + ex.Message); throw; } var reportPath = testContext.TestDir.Replace(" ", "_") + "_Report"; if (!Directory.Exists(reportPath)) { Directory.CreateDirectory(reportPath); } ReportFile = Path.Combine(reportPath, $"{_browserType.ToLower()}-report.html"); var extent = new ExtentReports(ReportFile, CultureInfo.GetCultureInfo("de"), ReplaceExisting: true, Order: DisplayOrder.NewestFirst); ReportLogger = new ReportLogger(reportPath, extent, Driver); App = new App(Driver, WebsiteBaseUrl, ReportLogger, timeOut); Driver.Manage().Window.Size = new System.Drawing.Size(1600, 1000); App.Open("/"); }
public static IWebDriver GetInternetExplorerBrowser() { var service = InternetExplorerDriverService.CreateDefaultService(DriverFolder); service.HideCommandPromptWindow = true; return(new InternetExplorerDriver(service, InternetExplorerOptions)); }
private static IWebDriver GetIeDriver() { var service = InternetExplorerDriverService.CreateDefaultService(Configuration.IeBinPath); var driver = new InternetExplorerDriver(service); driver.Manage().Window.Maximize(); return(driver); }
private static IWebDriver InternetExplorer(NavigatorSessionParameters session) { var service = InternetExplorerDriverService.CreateDefaultService(); service.HideCommandPromptWindow = session.HideCommandPromptWindow; return(new InternetExplorerDriver(service, new InternetExplorerOptions())); }
/// <summary> /// Starts a new instance of the web driver, installing or updating it as necessary. /// </summary> /// <param name="hideCommandWindow">Whether to hide the Selenium command window.</param> public override IWebDriver Start(bool hideCommandWindow = true) { var path = Install(); var driverService = InternetExplorerDriverService.CreateDefaultService(path); driverService.HideCommandPromptWindow = hideCommandWindow; return(new InternetExplorerDriver(driverService)); }
public static IWebDriver Create() { IWebDriver driver = null; switch (GetBrowser()) { case Browser.Chrome: driver = new ChromeDriver(DriverPath, DefaultChromeOptions()); break; case Browser.Firefox: var ffds = FirefoxDriverService.CreateDefaultService(DriverPath, "geckodriver.exe"); driver = new FirefoxDriver(ffds); MaximizeWindow(driver); break; case Browser.Edge: var edgeDriverService = EdgeDriverService.CreateDefaultService(DriverPath, "MicrosoftWebDriver.exe"); driver = new EdgeDriver(edgeDriverService); MaximizeWindow(driver); break; case Browser.Ie11: var ie11DriverService = InternetExplorerDriverService.CreateDefaultService(DriverPath, "IEDriverServer.exe"); driver = new InternetExplorerDriver(ie11DriverService, DefaultIe11Options()); MaximizeWindow(driver); break; case Browser.RemoteChrome: driver = RemoteWebDriver(DefaultChromeOptions().ToCapabilities()); break; case Browser.RemoteFirefox: driver = RemoteWebDriver(new FirefoxOptions().ToCapabilities()); MaximizeWindow(driver); break; case Browser.RemoteEdge: var edgeCapabilities = new EdgeOptions(); driver = RemoteWebDriver(edgeCapabilities.ToCapabilities()); MaximizeWindow(driver); break; case Browser.RemoteIe11: driver = RemoteWebDriver(DefaultIe11Options().ToCapabilities()); MaximizeWindow(driver); break; default: Assert.Inconclusive($"Browser: {GetBrowser()} is not supported"); break; } driver.SetDefaultImplicitWait(); return(driver); }
public IWebDriver Create(string logPath) { var internetExplorerDriverService = InternetExplorerDriverService.CreateDefaultService(); internetExplorerDriverService.LogFile = $"\"{logPath}\"";; internetExplorerDriverService.LoggingLevel = InternetExplorerDriverLogLevel.Debug; return(new InternetExplorerDriver(internetExplorerDriverService, new InternetExplorerOptions())); }
private void SetIEDriver() { KillProc("IEServerDriver"); var service = InternetExplorerDriverService.CreateDefaultService(); service.HideCommandPromptWindow = true; service.SuppressInitialDiagnosticInformation = true; driver = new InternetExplorerDriver(service); }
public void SetUp() { var VendorDirectory = System.IO.Directory.GetParent(System.AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.FullName + @"\Vendor"; var Service = InternetExplorerDriverService.CreateDefaultService(VendorDirectory); _driver = new InternetExplorerDriver(Service); _login = new LoginPage(_driver); _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); }
private static IWebDriver CreateDriver(InternetExplorerDriverService service, InternetExplorerOptions options) { //commandTimeout увеличен с дефолтных 60 до 180 секунд, т.к. при 60 время от времени получаем таймаут //подробнее тут: https://github.com/SeleniumHQ/selenium/wiki/DotNet-Bindings var internetExplorerDriver = new InternetExplorerDriver(service, options, TimeSpan.FromSeconds(180)); //internetExplorerDriver.Manage().Window.SetSize(configuration.WindowSize.Width, configuration.WindowSize.Height); return(internetExplorerDriver); }
/// <summary> /// Creates the web driver. /// </summary> /// <param name="configurationParameters">The configuration parameters.</param> /// <returns>The firefox webdriver.</returns> public static InternetExplorerDriver CreateWebDriver(ConfigurationParameters configurationParameters) { var driver = new InternetExplorerDriver( InternetExplorerDriverService.CreateDefaultService(configurationParameters.BrowsersConfiguration.IeDriverPath), CreateIeOPtions(), configurationParameters.BrowsersConfiguration.ChromeBrowserCommandTimeout); return(driver); }
/// <summary> /// Returns an instance of IE based driver. /// </summary> /// <returns>IE based driver.</returns> private static IWebDriver IeWebDriver() { // get machine processor architecture String getProcessorArchitecture = Registry.GetValue( "HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\Environment" , "PROCESSOR_ARCHITECTURE", null).ToString(); // get installed browser's version in machine Dictionary <string, string> browserList = GetBrowserDetails(); // get Ie driver path based on Ie version installed in String getIeDriverPath; if (getProcessorArchitecture.Contains("64") && (browserList.ContainsKey("IE") && browserList["IE"].Contains("10.") || (browserList.ContainsKey("IE") && browserList["IE"].Contains("11.")))) { // get Ie driver path getIeDriverPath = (Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\..\\..\\..\\..\\ExternalAssemblies\\x86").Replace("file:\\", ""); } else { // Ie driver path getIeDriverPath = (Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\..\\..\\..\\..\\ExternalAssemblies\\" + ((getProcessorArchitecture == "x86") ? "x86" : "x64")) .Replace("file:\\", ""); } // start internet explorer driver service InternetExplorerDriverService ieservice = InternetExplorerDriverService.CreateDefaultService(getIeDriverPath); ieservice.LoggingLevel = InternetExplorerDriverLogLevel.Info; // get path for save log execution file String getExecutingPath = new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName; if (getExecutingPath != null) { ieservice.LogFile = Path.Combine(getExecutingPath, "Log", "IEDriver" + DateTime.Now.Ticks + ".log"); } // set internet explorer options var options = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true, UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Ignore, IgnoreZoomLevel = true, EnableNativeEvents = true, BrowserAttachTimeout = TimeSpan.FromMinutes(20), EnablePersistentHover = false }; // create internet explorer driver object IWebDriver webDriver = new InternetExplorerDriver(ieservice, options, TimeSpan.FromMinutes(20)); // set webDriver page load duration webDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromMinutes(20)); // set cursor position center of the screen Cursor.Position = new Point(Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2); return(webDriver); }
public static IWebDriver CreateWebDriver(BrowserOptions options) { IWebDriver driver; switch (options.BrowserType) { case BrowserType.Chrome: var chromeService = ChromeDriverService.CreateDefaultService(); chromeService.HideCommandPromptWindow = options.HideDiagnosticWindow; driver = new ChromeDriver(chromeService, options.ToChrome()); break; case BrowserType.IE: var ieService = InternetExplorerDriverService.CreateDefaultService(); ieService.SuppressInitialDiagnosticInformation = options.HideDiagnosticWindow; driver = new InternetExplorerDriver(ieService, options.ToInternetExplorer(), TimeSpan.FromMinutes(20)); break; case BrowserType.Firefox: var ffService = FirefoxDriverService.CreateDefaultService(); ffService.HideCommandPromptWindow = options.HideDiagnosticWindow; driver = new FirefoxDriver(ffService); driver.Manage().Timeouts().ImplicitWait = new TimeSpan(0, 0, 5); break; case BrowserType.PhantomJs: driver = new PhantomJSDriver(options.DriversPath); break; case BrowserType.Edge: var edgeService = EdgeDriverService.CreateDefaultService(); edgeService.HideCommandPromptWindow = options.HideDiagnosticWindow; driver = new EdgeDriver(edgeService, options.ToEdge(), TimeSpan.FromMinutes(20)); break; default: throw new InvalidOperationException( $"The browser type '{options.BrowserType}' is not recognized."); } driver.Manage().Timeouts().PageLoad = options.PageLoadTimeout; if (options.StartMaximized && options.BrowserType != BrowserType.Chrome) //Handle Chrome in the Browser Options { driver.Manage().Window.Maximize(); } if (options.FireEvents || options.EnableRecording) { // Wrap the newly created driver. driver = new EventFiringWebDriver(driver); } return(driver); }
private static InternetExplorerDriverService GetIEDriverService() { string path = @"C:\Program Files\internet explorer\"; string name = "iexplore.exe"; InternetExplorerDriverService ieService = InternetExplorerDriverService.CreateDefaultService(); //ieService. return(ieService); }
private static IWebDriver IeInitializations() { var service = InternetExplorerDriverService.CreateDefaultService(_driverPath); var options = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true }; return(new InternetExplorerDriver(service, options)); }
internal static InternetExplorerDriverService GetInternetExplorerDriverService() { var path = FileUtils.GetCurrentlyExecutingDirectory(); var internetExplorerDriverService = InternetExplorerDriverService.CreateDefaultService(path, "IEDriverServer.exe"); internetExplorerDriverService.HideCommandPromptWindow = false; internetExplorerDriverService.LoggingLevel = InternetExplorerDriverLogLevel.Trace; internetExplorerDriverService.LogFile = appConfigMember.IELogFileLocation; return(internetExplorerDriverService); }
public void start() { InternetExplorerDriverService service = InternetExplorerDriverService.CreateDefaultService(); service.LoggingLevel = InternetExplorerDriverLogLevel.Debug; service.LogFile = "D:\\iedriver.log"; driver = new InternetExplorerDriver(service); // this.driver = new TWebDriver(); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); }
protected virtual IWebDriver _ie() { var service = InternetExplorerDriverService.CreateDefaultService(Program.Options.Dir("drivers") + DriverExtension); var options = new InternetExplorerOptions(); service.SuppressInitialDiagnosticInformation = true; options.IntroduceInstabilityByIgnoringProtectedModeSettings = true; return(new InternetExplorerDriver(service, options)); }
/// <summary> /// Creates the web driver. /// </summary> /// <param name="options">The options.</param> /// <returns>The webdriver.</returns> public static InternetExplorerDriver CreateWebDriver(IWritableOptions <ConfigurationParameters> options) { CloseIEWebDriver(); var driver = new InternetExplorerDriver( InternetExplorerDriverService.CreateDefaultService(options?.Value.BrowsersConfiguration.IeDriverPath), CreateIeOPtions(), TimeSpan.FromSeconds(options.Value.BrowsersConfiguration.CommandTimeout)); return(driver); }
public IWebDriver CreateDriver() { var z = new ChromeOptions(); var x = new FirefoxOptions(); var v = new InternetExplorerOptions(); var dc = new DesiredCapabilities(); var o = ((DesiredCapabilities)v). var r = new InternetExplorerDriver(InternetExplorerDriverService.CreateDefaultService("path"), v); return(new RemoteWebDriver()); }