Skip to content

Commit

Permalink
Adding type safe support to InternetExplorerOptions for page load str…
Browse files Browse the repository at this point in the history
…ategy
  • Loading branch information
jimevans committed Apr 16, 2015
1 parent 5b9bca3 commit 889904a
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/IE/InternetExplorerDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
56 changes: 54 additions & 2 deletions dotnet/src/webdriver/IE/InternetExplorerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,29 @@ public enum InternetExplorerUnexpectedAlertBehavior
Dismiss
}

public enum InternetExplorerPageLoadStrategy
{
/// <summary>
/// Indicates the behavior is not set.
/// </summary>
Default,

/// <summary>
/// Waits for pages to load and ready state to be 'complete'.
/// </summary>
Normal,

/// <summary>
/// Waits for pages to load and for ready state to be 'interactive' or 'complete'.
/// </summary>
Eager,

/// <summary>
/// Does not wait for pages to load, returning immediately.
/// </summary>
None
}

/// <summary>
/// Class to manage options specific to <see cref="InternetExplorerDriver"/>
/// </summary>
Expand Down Expand Up @@ -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;
Expand All @@ -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<string, object> additionalCapabilities = new Dictionary<string, object>();

Expand Down Expand Up @@ -193,6 +217,16 @@ public InternetExplorerUnexpectedAlertBehavior UnexpectedAlertBehavior
set { this.unexpectedAlertBehavior = value; }
}

/// <summary>
/// Gets or sets the value for describing how the browser is to wait for pages to load in the IE driver.
/// Defaults to <see cref="InternetExplorerPageLoadStrategy.Default"/>.
/// </summary>
public InternetExplorerPageLoadStrategy PageLoadStrategy
{
get { return this.pageLoadStrategy; }
set { this.pageLoadStrategy = value; }
}

/// <summary>
/// Gets or sets a value indicating whether to enable persistently sending WM_MOUSEMOVE messages
/// to the IE window during a mouse hover.
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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));
Expand Down
5 changes: 5 additions & 0 deletions dotnet/src/webdriver/Remote/CapabilityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,10 @@ public static class CapabilityType
/// Capability name used to indicate how the browser handles unexpected alerts.
/// </summary>
public static readonly string UnexpectedAlertBehavior = "unexpectedAlertBehaviour";

/// <summary>
/// Capability name used to indicate the page load strategy for the browser.
/// </summary>
public static readonly string PageLoadStrategy = "pageLoadStrategy";
}
}

0 comments on commit 889904a

Please sign in to comment.