Skip to content

Commit

Permalink
Moving .NET IE driver command-line args into capabilities.
Browse files Browse the repository at this point in the history
This is to sync up the .NET bindings with 2.33.0.7 of IEDriverServer.exe.
  • Loading branch information
jimevans committed Jul 16, 2013
1 parent c6d0a96 commit 28f26be
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
32 changes: 0 additions & 32 deletions dotnet/src/WebDriver/IE/InternetExplorerDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public sealed class InternetExplorerDriverService : DriverService
private string host = string.Empty;
private string logFile = string.Empty;
private string libraryExtractionPath = string.Empty;
private bool forceCreateProcessApi;
private string internetExplorerCommandLineSwitches = string.Empty;

/// <summary>
/// Initializes a new instance of the InternetExplorerDriverService class.
Expand Down Expand Up @@ -92,27 +90,6 @@ public string LibraryExtractionPath
set { this.libraryExtractionPath = value; }
}

/// <summary>
/// Gets or sets a value indicating whether the service should force the use of
/// the Windows CreateProcess API when launching Internet Explorer. Defaults to false.
/// </summary>
public bool ForceCreateProcessApi
{
get { return this.forceCreateProcessApi; }
set { this.forceCreateProcessApi = value; }
}

/// <summary>
/// Gets or sets the switches to be used on the command line when launching
/// Internet Explorer. This property is only used when <see cref="ForceCreateProcessApi"/>
/// is set to <see langword="true"/>.
/// </summary>
public string InternetExplorerCommandLineSwitches
{
get { return this.internetExplorerCommandLineSwitches; }
set { this.internetExplorerCommandLineSwitches = value; }
}

/// <summary>
/// Gets the command-line arguments for the driver service.
/// </summary>
Expand Down Expand Up @@ -146,15 +123,6 @@ protected override string CommandLineArguments
argsBuilder.Append(" -silent");
}

if (this.forceCreateProcessApi)
{
argsBuilder.Append(" -force-createprocess");
if (!string.IsNullOrEmpty(this.internetExplorerCommandLineSwitches))
{
argsBuilder.Append(string.Format(CultureInfo.InvariantCulture, " -ie-switches={0}", this.internetExplorerCommandLineSwitches));
}
}

return argsBuilder.ToString();
}
}
Expand Down
38 changes: 37 additions & 1 deletion dotnet/src/WebDriver/IE/InternetExplorerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,18 @@ public class InternetExplorerOptions
private const string ElementScrollBehaviorCapability = "elementScrollBehavior";
private const string RequireWindowFocusCapability = "requireWindowFocus";
private const string BrowserAttachTimeoutCapability = "browserAttachTimeout";
private const string BrowserCommandLineSwitchesCapability = "ie.browserCommandLineSwitches";
private const string ForceCreateProcessApiCapability = "ie.forceCreateProcessApi";

private bool ignoreProtectedModeSettings;
private bool ignoreZoomLevel;
private bool enableNativeEvents = true;
private bool requireWindowFocus;
private bool enablePersistentHover = true;
private bool forceCreateProcessApi;
private TimeSpan browserAttachTimeout = TimeSpan.MinValue;
private string initialBrowserUrl = string.Empty;
private string browserCommandLineArguments = string.Empty;
private InternetExplorerElementScrollBehavior elementScrollBehavior = InternetExplorerElementScrollBehavior.Top;
private InternetExplorerUnexpectedAlertBehavior unexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Default;
private Dictionary<string, object> additionalCapabilities = new Dictionary<string, object>();
Expand Down Expand Up @@ -200,6 +204,27 @@ public TimeSpan BrowserAttachTimeout
set { this.browserAttachTimeout = value; }
}

/// <summary>
/// Gets or sets a value indicating whether to force the use of the Windows CreateProcess API
/// when launching Internet Explorer. The default value is <see langword="false"/>.
/// </summary>
public bool ForceCreateProcessApi
{
get { return this.forceCreateProcessApi; }
set { this.forceCreateProcessApi = value; }
}

/// <summary>
/// Gets or sets the command line arguments used in launching Internet Explorer when the
/// Windows CreateProcess API is used. This property only has an effect when the
/// <see cref="ForceCreateProcessApi"/> is <see langword="true"/>.
/// </summary>
public string BrowserCommandLineArguments
{
get { return this.browserCommandLineArguments; }
set { this.browserCommandLineArguments = value; }
}

/// <summary>
/// Provides a means to add additional capabilities not yet added as type safe options
/// for the Internet Explorer driver.
Expand All @@ -222,7 +247,9 @@ public void AddAdditionalCapability(string capabilityName, object capabilityValu
capabilityName == CapabilityType.UnexpectedAlertBehavior ||
capabilityName == EnablePersistentHoverCapability ||
capabilityName == RequireWindowFocusCapability ||
capabilityName == BrowserAttachTimeoutCapability)
capabilityName == BrowserAttachTimeoutCapability ||
capabilityName == ForceCreateProcessApiCapability ||
capabilityName == BrowserCommandLineSwitchesCapability)
{
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 @@ -295,6 +322,15 @@ public ICapabilities ToCapabilities()
capabilities.SetCapability(BrowserAttachTimeoutCapability, Convert.ToInt32(this.browserAttachTimeout.TotalMilliseconds));
}

if (this.forceCreateProcessApi)
{
capabilities.SetCapability(ForceCreateProcessApiCapability, true);
if (!string.IsNullOrEmpty(this.browserCommandLineArguments))
{
capabilities.SetCapability(BrowserCommandLineSwitchesCapability, this.browserCommandLineArguments);
}
}

foreach (KeyValuePair<string, object> pair in this.additionalCapabilities)
{
capabilities.SetCapability(pair.Key, pair.Value);
Expand Down

0 comments on commit 28f26be

Please sign in to comment.