Skip to content

Commit

Permalink
Adding type-safe options for EdgeDriverService command line switches
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed May 24, 2016
1 parent ac7c965 commit 04a346a
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion dotnet/src/webdriver/Edge/EdgeDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// </copyright>

using System;
using System.Globalization;
using System.Text;
using OpenQA.Selenium.Internal;

namespace OpenQA.Selenium.Edge
Expand All @@ -28,6 +30,9 @@ public sealed class EdgeDriverService : DriverService
{
private const string MicrosoftWebDriverServiceFileName = "MicrosoftWebDriver.exe";
private static readonly Uri MicrosoftWebDriverDownloadUrl = new Uri("http://go.microsoft.com/fwlink/?LinkId=619687");
private string host;
private string package;
private bool useVerboseLogging;

/// <summary>
/// Initializes a new instance of the <see cref="EdgeDriverService"/> class.
Expand All @@ -40,14 +45,69 @@ private EdgeDriverService(string executablePath, string executableFileName, int
{
}

/// <summary>
/// Gets or sets the value of the host adapter on which the Edge driver service should listen for connections.
/// </summary>
public string Host
{
get { return this.host; }
set { this.host = value; }
}

/// <summary>
/// Gets or sets the value of the package the Edge driver service will launch and automate.
/// </summary>
public string Package
{
get { return this.package; }
set { this.package = value; }
}

/// <summary>
/// Gets or sets a value indicating whether the service should use verbose logging.
/// </summary>
public bool UseVerboseLogging
{
get { return this.useVerboseLogging; }
set { this.useVerboseLogging = value; }
}

/// <summary>
/// Gets the command-line arguments for the driver service.
/// </summary>
protected override string CommandLineArguments
{
get
{
StringBuilder argsBuilder = new StringBuilder(base.CommandLineArguments);
if (!string.IsNullOrEmpty(this.host))
{
argsBuilder.Append(string.Format(CultureInfo.InvariantCulture, " --host={0}", this.host));
}

if (!string.IsNullOrEmpty(this.package))
{
argsBuilder.Append(string.Format(CultureInfo.InvariantCulture, " --package={0}", this.package));
}

if (this.useVerboseLogging)
{
argsBuilder.Append(" --verbose");
}

return argsBuilder.ToString();
}
}

/// <summary>
/// Creates a default instance of the EdgeDriverService.
/// </summary>
/// <returns>A EdgeDriverService that implements default settings.</returns>
public static EdgeDriverService CreateDefaultService()
{
string serviceDirectory = DriverService.FindDriverServiceExecutable(MicrosoftWebDriverServiceFileName, MicrosoftWebDriverDownloadUrl);
return CreateDefaultService(serviceDirectory);
EdgeDriverService service = CreateDefaultService(serviceDirectory);
return service;
}

/// <summary>
Expand Down

0 comments on commit 04a346a

Please sign in to comment.