Skip to content

Commit e66fbf5

Browse files
authored
[dotnet] allow user to start service before creating driver (#12816)
1 parent 7397877 commit e66fbf5

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

dotnet/src/webdriver/Chrome/ChromeDriverService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ private ChromeDriverService(string executablePath, string executableFileName, in
4141
{
4242
}
4343

44+
/// <inheritdoc />
45+
protected override DriverOptions GetDefaultDriverOptions()
46+
{
47+
return new ChromeOptions();
48+
}
49+
4450
/// <summary>
4551
/// Creates a default instance of the ChromeDriverService.
4652
/// </summary>

dotnet/src/webdriver/DriverService.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ public void Start()
262262
return;
263263
}
264264

265+
if (this.driverServicePath == null)
266+
{
267+
DriverFinder.FullPath(this.GetDefaultDriverOptions());
268+
}
269+
265270
this.driverServiceProcess = new Process();
266271
this.driverServiceProcess.StartInfo.FileName = Path.Combine(this.driverServicePath, this.driverServiceExecutableName);
267272
this.driverServiceProcess.StartInfo.Arguments = this.CommandLineArguments;
@@ -283,6 +288,12 @@ public void Start()
283288
}
284289
}
285290

291+
/// <summary>
292+
/// The browser options instance that corresponds to the driver service
293+
/// </summary>
294+
/// <returns></returns>
295+
protected abstract DriverOptions GetDefaultDriverOptions();
296+
286297
/// <summary>
287298
/// Releases all resources associated with this <see cref="DriverService"/>.
288299
/// </summary>

dotnet/src/webdriver/Edge/EdgeDriverService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ private EdgeDriverService(string executablePath, string executableFileName, int
4141
{
4242
}
4343

44+
/// <inheritdoc />
45+
protected override DriverOptions GetDefaultDriverOptions()
46+
{
47+
return new EdgeOptions();
48+
}
49+
4450
/// <summary>
4551
/// Gets or sets a value indicating whether the service should use verbose logging.
4652
/// </summary>

dotnet/src/webdriver/Firefox/FirefoxDriverService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ private FirefoxDriverService(string executablePath, string executableFileName, i
5050
{
5151
}
5252

53+
/// <inheritdoc />
54+
protected override DriverOptions GetDefaultDriverOptions()
55+
{
56+
return new FirefoxOptions();
57+
}
58+
5359
/// <summary>
5460
/// Gets or sets the location of the Firefox binary executable.
5561
/// </summary>

dotnet/src/webdriver/IE/InternetExplorerDriverService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ private InternetExplorerDriverService(string executablePath, string executableFi
4848
{
4949
}
5050

51+
/// <inheritdoc />
52+
protected override DriverOptions GetDefaultDriverOptions()
53+
{
54+
return new InternetExplorerOptions();
55+
}
56+
5157
/// <summary>
5258
/// Gets or sets the value of the host adapter on which the IEDriverServer should listen for connections.
5359
/// </summary>

dotnet/src/webdriver/Safari/SafariDriverService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ private SafariDriverService(string executablePath, string executableFileName, in
4646
{
4747
}
4848

49+
/// <inheritdoc />
50+
protected override DriverOptions GetDefaultDriverOptions()
51+
{
52+
return new SafariOptions();
53+
}
54+
4955
/// <summary>
5056
/// Gets or sets a value indicating whether to use the default open-source project
5157
/// dialect of the protocol instead of the default dialect compliant with the

0 commit comments

Comments
 (0)