From 889904aaf49e0581da56e85c763a8269a605ca61 Mon Sep 17 00:00:00 2001 From: Jim Evans Date: Thu, 16 Apr 2015 14:30:55 -0400 Subject: [PATCH] Adding type safe support to InternetExplorerOptions for page load strategy --- .../IE/InternetExplorerDriverService.cs | 2 +- .../webdriver/IE/InternetExplorerOptions.cs | 56 ++++++++++++++++++- dotnet/src/webdriver/Remote/CapabilityType.cs | 5 ++ 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs b/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs index 8dc9360d2d879..8c87f05f84a7c 100644 --- a/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs +++ b/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs @@ -33,7 +33,7 @@ public sealed class InternetExplorerDriverService : DriverService private const string InternetExplorerDriverServiceFileName = "IEDriverServer.exe"; private static readonly Uri InternetExplorerDriverDownloadUrl = new Uri("http://selenium-release.storage.googleapis.com/index.html"); - private InternetExplorerDriverLogLevel loggingLevel = InternetExplorerDriverLogLevel.Fatal; + private InternetExplorerDriverLogLevel loggingLevel = InternetExplorerDriverLogLevel.Debug; private InternetExplorerDriverEngine engineImplementation = InternetExplorerDriverEngine.Legacy; private string host = string.Empty; private string logFile = string.Empty; diff --git a/dotnet/src/webdriver/IE/InternetExplorerOptions.cs b/dotnet/src/webdriver/IE/InternetExplorerOptions.cs index eff5552ddbc70..18dd3e15da15b 100644 --- a/dotnet/src/webdriver/IE/InternetExplorerOptions.cs +++ b/dotnet/src/webdriver/IE/InternetExplorerOptions.cs @@ -66,6 +66,29 @@ public enum InternetExplorerUnexpectedAlertBehavior Dismiss } + public enum InternetExplorerPageLoadStrategy + { + /// + /// Indicates the behavior is not set. + /// + Default, + + /// + /// Waits for pages to load and ready state to be 'complete'. + /// + Normal, + + /// + /// Waits for pages to load and for ready state to be 'interactive' or 'complete'. + /// + Eager, + + /// + /// Does not wait for pages to load, returning immediately. + /// + None + } + /// /// Class to manage options specific to /// @@ -109,7 +132,7 @@ public class InternetExplorerOptions private bool requireWindowFocus; private bool enablePersistentHover = true; private bool forceCreateProcessApi; - private bool forceShellWindowsApi; + private bool forceShellWindowsApi = true; private bool usePerProcessProxy; private bool ensureCleanSession; private bool validateCookieDocumentType = true; @@ -118,6 +141,7 @@ public class InternetExplorerOptions private string browserCommandLineArguments = string.Empty; private InternetExplorerElementScrollBehavior elementScrollBehavior = InternetExplorerElementScrollBehavior.Top; private InternetExplorerUnexpectedAlertBehavior unexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Default; + private InternetExplorerPageLoadStrategy pageLoadStrategy = InternetExplorerPageLoadStrategy.Default; private Proxy proxy; private Dictionary additionalCapabilities = new Dictionary(); @@ -193,6 +217,16 @@ public InternetExplorerUnexpectedAlertBehavior UnexpectedAlertBehavior set { this.unexpectedAlertBehavior = value; } } + /// + /// Gets or sets the value for describing how the browser is to wait for pages to load in the IE driver. + /// Defaults to . + /// + public InternetExplorerPageLoadStrategy PageLoadStrategy + { + get { return this.pageLoadStrategy; } + set { this.pageLoadStrategy = value; } + } + /// /// Gets or sets a value indicating whether to enable persistently sending WM_MOUSEMOVE messages /// to the IE window during a mouse hover. @@ -321,7 +355,8 @@ public void AddAdditionalCapability(string capabilityName, object capabilityValu capabilityName == CapabilityType.Proxy || capabilityName == UsePerProcessProxyCapability || capabilityName == EnsureCleanSessionCapability || - capabilityName == ValidateCookieDocumentTypeCapability) + capabilityName == ValidateCookieDocumentTypeCapability || + capabilityName == CapabilityType.PageLoadStrategy) { string message = string.Format(CultureInfo.InvariantCulture, "There is already an option for the {0} capability. Please use that instead.", capabilityName); throw new ArgumentException(message, "capabilityName"); @@ -389,6 +424,23 @@ public ICapabilities ToCapabilities() capabilities.SetCapability(CapabilityType.UnexpectedAlertBehavior, unexpectedAlertBehaviorSetting); } + if (this.pageLoadStrategy != InternetExplorerPageLoadStrategy.Default) + { + string pageLoadStrategySetting = "normal"; + switch (this.pageLoadStrategy) + { + case InternetExplorerPageLoadStrategy.Eager: + pageLoadStrategySetting = "eager"; + break; + + case InternetExplorerPageLoadStrategy.None: + pageLoadStrategySetting = "none"; + break; + } + + capabilities.SetCapability(CapabilityType.PageLoadStrategy, pageLoadStrategySetting); + } + if (this.browserAttachTimeout != TimeSpan.MinValue) { capabilities.SetCapability(BrowserAttachTimeoutCapability, Convert.ToInt32(this.browserAttachTimeout.TotalMilliseconds)); diff --git a/dotnet/src/webdriver/Remote/CapabilityType.cs b/dotnet/src/webdriver/Remote/CapabilityType.cs index abbee38e8dbd7..2fb090fd589f9 100644 --- a/dotnet/src/webdriver/Remote/CapabilityType.cs +++ b/dotnet/src/webdriver/Remote/CapabilityType.cs @@ -86,5 +86,10 @@ public static class CapabilityType /// Capability name used to indicate how the browser handles unexpected alerts. /// public static readonly string UnexpectedAlertBehavior = "unexpectedAlertBehaviour"; + + /// + /// Capability name used to indicate the page load strategy for the browser. + /// + public static readonly string PageLoadStrategy = "pageLoadStrategy"; } }