Skip to content

Commit 889904a

Browse files
committed
Adding type safe support to InternetExplorerOptions for page load strategy
1 parent 5b9bca3 commit 889904a

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

dotnet/src/webdriver/IE/InternetExplorerDriverService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public sealed class InternetExplorerDriverService : DriverService
3333
private const string InternetExplorerDriverServiceFileName = "IEDriverServer.exe";
3434
private static readonly Uri InternetExplorerDriverDownloadUrl = new Uri("http://selenium-release.storage.googleapis.com/index.html");
3535

36-
private InternetExplorerDriverLogLevel loggingLevel = InternetExplorerDriverLogLevel.Fatal;
36+
private InternetExplorerDriverLogLevel loggingLevel = InternetExplorerDriverLogLevel.Debug;
3737
private InternetExplorerDriverEngine engineImplementation = InternetExplorerDriverEngine.Legacy;
3838
private string host = string.Empty;
3939
private string logFile = string.Empty;

dotnet/src/webdriver/IE/InternetExplorerOptions.cs

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,29 @@ public enum InternetExplorerUnexpectedAlertBehavior
6666
Dismiss
6767
}
6868

69+
public enum InternetExplorerPageLoadStrategy
70+
{
71+
/// <summary>
72+
/// Indicates the behavior is not set.
73+
/// </summary>
74+
Default,
75+
76+
/// <summary>
77+
/// Waits for pages to load and ready state to be 'complete'.
78+
/// </summary>
79+
Normal,
80+
81+
/// <summary>
82+
/// Waits for pages to load and for ready state to be 'interactive' or 'complete'.
83+
/// </summary>
84+
Eager,
85+
86+
/// <summary>
87+
/// Does not wait for pages to load, returning immediately.
88+
/// </summary>
89+
None
90+
}
91+
6992
/// <summary>
7093
/// Class to manage options specific to <see cref="InternetExplorerDriver"/>
7194
/// </summary>
@@ -109,7 +132,7 @@ public class InternetExplorerOptions
109132
private bool requireWindowFocus;
110133
private bool enablePersistentHover = true;
111134
private bool forceCreateProcessApi;
112-
private bool forceShellWindowsApi;
135+
private bool forceShellWindowsApi = true;
113136
private bool usePerProcessProxy;
114137
private bool ensureCleanSession;
115138
private bool validateCookieDocumentType = true;
@@ -118,6 +141,7 @@ public class InternetExplorerOptions
118141
private string browserCommandLineArguments = string.Empty;
119142
private InternetExplorerElementScrollBehavior elementScrollBehavior = InternetExplorerElementScrollBehavior.Top;
120143
private InternetExplorerUnexpectedAlertBehavior unexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Default;
144+
private InternetExplorerPageLoadStrategy pageLoadStrategy = InternetExplorerPageLoadStrategy.Default;
121145
private Proxy proxy;
122146
private Dictionary<string, object> additionalCapabilities = new Dictionary<string, object>();
123147

@@ -193,6 +217,16 @@ public InternetExplorerUnexpectedAlertBehavior UnexpectedAlertBehavior
193217
set { this.unexpectedAlertBehavior = value; }
194218
}
195219

220+
/// <summary>
221+
/// Gets or sets the value for describing how the browser is to wait for pages to load in the IE driver.
222+
/// Defaults to <see cref="InternetExplorerPageLoadStrategy.Default"/>.
223+
/// </summary>
224+
public InternetExplorerPageLoadStrategy PageLoadStrategy
225+
{
226+
get { return this.pageLoadStrategy; }
227+
set { this.pageLoadStrategy = value; }
228+
}
229+
196230
/// <summary>
197231
/// Gets or sets a value indicating whether to enable persistently sending WM_MOUSEMOVE messages
198232
/// to the IE window during a mouse hover.
@@ -321,7 +355,8 @@ public void AddAdditionalCapability(string capabilityName, object capabilityValu
321355
capabilityName == CapabilityType.Proxy ||
322356
capabilityName == UsePerProcessProxyCapability ||
323357
capabilityName == EnsureCleanSessionCapability ||
324-
capabilityName == ValidateCookieDocumentTypeCapability)
358+
capabilityName == ValidateCookieDocumentTypeCapability ||
359+
capabilityName == CapabilityType.PageLoadStrategy)
325360
{
326361
string message = string.Format(CultureInfo.InvariantCulture, "There is already an option for the {0} capability. Please use that instead.", capabilityName);
327362
throw new ArgumentException(message, "capabilityName");
@@ -389,6 +424,23 @@ public ICapabilities ToCapabilities()
389424
capabilities.SetCapability(CapabilityType.UnexpectedAlertBehavior, unexpectedAlertBehaviorSetting);
390425
}
391426

427+
if (this.pageLoadStrategy != InternetExplorerPageLoadStrategy.Default)
428+
{
429+
string pageLoadStrategySetting = "normal";
430+
switch (this.pageLoadStrategy)
431+
{
432+
case InternetExplorerPageLoadStrategy.Eager:
433+
pageLoadStrategySetting = "eager";
434+
break;
435+
436+
case InternetExplorerPageLoadStrategy.None:
437+
pageLoadStrategySetting = "none";
438+
break;
439+
}
440+
441+
capabilities.SetCapability(CapabilityType.PageLoadStrategy, pageLoadStrategySetting);
442+
}
443+
392444
if (this.browserAttachTimeout != TimeSpan.MinValue)
393445
{
394446
capabilities.SetCapability(BrowserAttachTimeoutCapability, Convert.ToInt32(this.browserAttachTimeout.TotalMilliseconds));

dotnet/src/webdriver/Remote/CapabilityType.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,10 @@ public static class CapabilityType
8686
/// Capability name used to indicate how the browser handles unexpected alerts.
8787
/// </summary>
8888
public static readonly string UnexpectedAlertBehavior = "unexpectedAlertBehaviour";
89+
90+
/// <summary>
91+
/// Capability name used to indicate the page load strategy for the browser.
92+
/// </summary>
93+
public static readonly string PageLoadStrategy = "pageLoadStrategy";
8994
}
9095
}

0 commit comments

Comments
 (0)