/// <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 }); }
/// <summary> /// Sets the Internet Explorer Options from the app.config file /// </summary> private void SetInternetExplorerOptions() { try { InternetExplorerElementScrollBehavior scroll = InternetExplorerElementScrollBehavior.Bottom; Enum.TryParse(InternetExplorer.ScrollBehavior, out scroll); bool.TryParse(InternetExplorer.EnableFullPageScreenshot, out bool screenshot); bool.TryParse(InternetExplorer.EnableNativeEvents, out bool native); bool.TryParse(InternetExplorer.EnablePersistentHover, out bool hover); bool.TryParse(InternetExplorer.EnsureCleanSession, out bool cleanSession); bool.TryParse(InternetExplorer.ForceCreateProcessApi, out bool forceCreate); bool.TryParse(InternetExplorer.ForceShellWindowsApi, out bool forceShell); bool.TryParse(InternetExplorer.IgnoreZoomLevel, out bool ignoreZoom); bool.TryParse(InternetExplorer.IntroduceInstability, out bool instability); bool.TryParse(InternetExplorer.RequireWindowFocus, out bool requireFocus); bool.TryParse(InternetExplorer.UsePerProcessProxy, out bool perProcess); string cmdLine = InternetExplorer.CommandLineArguments; string url = InternetExplorer.InitialBrowserUrl; InternetExplorerOptions options = new InternetExplorerOptions { BrowserAttachTimeout = BaseSettings.Timeout }; options.BrowserCommandLineArguments = cmdLine ?? null; options.ElementScrollBehavior = scroll; // options.EnableFullPageScreenshot = screenshot; options.EnableNativeEvents = native; options.EnablePersistentHover = hover; options.EnsureCleanSession = cleanSession; options.FileUploadDialogTimeout = InternetExplorer.FileUploadTimeout; options.ForceCreateProcessApi = forceCreate; options.ForceShellWindowsApi = forceShell; options.IgnoreZoomLevel = ignoreZoom; options.InitialBrowserUrl = url; options.IntroduceInstabilityByIgnoringProtectedModeSettings = instability; // options.Proxy = IEProxy; options.RequireWindowFocus = requireFocus; // options.UnexpectedAlertBehavior = alert; options.UsePerProcessProxy = perProcess; Options = options; } catch (Exception ex) { switch (BaseSettings.DebugLevel) { case EnumConsoleDebugLevel.Human: Console.Out.WriteLine("Could not set the internet explorer driver options settings."); Console.Out.WriteLine("Please investigate the changes you have made to your config file."); break; case EnumConsoleDebugLevel.NotSpecified: case EnumConsoleDebugLevel.Message: Console.Out.WriteLine(ex.Message); break; case EnumConsoleDebugLevel.StackTrace: Console.Out.WriteLine(ex.Message); Console.Out.WriteLine(ex.StackTrace); break; } } }