Skip to content

Commit 04a346a

Browse files
committed
Adding type-safe options for EdgeDriverService command line switches
1 parent ac7c965 commit 04a346a

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

dotnet/src/webdriver/Edge/EdgeDriverService.cs

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// </copyright>
1818

1919
using System;
20+
using System.Globalization;
21+
using System.Text;
2022
using OpenQA.Selenium.Internal;
2123

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

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

48+
/// <summary>
49+
/// Gets or sets the value of the host adapter on which the Edge driver service should listen for connections.
50+
/// </summary>
51+
public string Host
52+
{
53+
get { return this.host; }
54+
set { this.host = value; }
55+
}
56+
57+
/// <summary>
58+
/// Gets or sets the value of the package the Edge driver service will launch and automate.
59+
/// </summary>
60+
public string Package
61+
{
62+
get { return this.package; }
63+
set { this.package = value; }
64+
}
65+
66+
/// <summary>
67+
/// Gets or sets a value indicating whether the service should use verbose logging.
68+
/// </summary>
69+
public bool UseVerboseLogging
70+
{
71+
get { return this.useVerboseLogging; }
72+
set { this.useVerboseLogging = value; }
73+
}
74+
75+
/// <summary>
76+
/// Gets the command-line arguments for the driver service.
77+
/// </summary>
78+
protected override string CommandLineArguments
79+
{
80+
get
81+
{
82+
StringBuilder argsBuilder = new StringBuilder(base.CommandLineArguments);
83+
if (!string.IsNullOrEmpty(this.host))
84+
{
85+
argsBuilder.Append(string.Format(CultureInfo.InvariantCulture, " --host={0}", this.host));
86+
}
87+
88+
if (!string.IsNullOrEmpty(this.package))
89+
{
90+
argsBuilder.Append(string.Format(CultureInfo.InvariantCulture, " --package={0}", this.package));
91+
}
92+
93+
if (this.useVerboseLogging)
94+
{
95+
argsBuilder.Append(" --verbose");
96+
}
97+
98+
return argsBuilder.ToString();
99+
}
100+
}
101+
43102
/// <summary>
44103
/// Creates a default instance of the EdgeDriverService.
45104
/// </summary>
46105
/// <returns>A EdgeDriverService that implements default settings.</returns>
47106
public static EdgeDriverService CreateDefaultService()
48107
{
49108
string serviceDirectory = DriverService.FindDriverServiceExecutable(MicrosoftWebDriverServiceFileName, MicrosoftWebDriverDownloadUrl);
50-
return CreateDefaultService(serviceDirectory);
109+
EdgeDriverService service = CreateDefaultService(serviceDirectory);
110+
return service;
51111
}
52112

53113
/// <summary>

0 commit comments

Comments
 (0)