Skip to content

Commit

Permalink
[dotnet] allow user to start service before creating driver (#12816)
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner authored Sep 25, 2023
1 parent 7397877 commit e66fbf5
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dotnet/src/webdriver/Chrome/ChromeDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ private ChromeDriverService(string executablePath, string executableFileName, in
{
}

/// <inheritdoc />
protected override DriverOptions GetDefaultDriverOptions()
{
return new ChromeOptions();
}

/// <summary>
/// Creates a default instance of the ChromeDriverService.
/// </summary>
Expand Down
11 changes: 11 additions & 0 deletions dotnet/src/webdriver/DriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ public void Start()
return;
}

if (this.driverServicePath == null)
{
DriverFinder.FullPath(this.GetDefaultDriverOptions());
}

this.driverServiceProcess = new Process();
this.driverServiceProcess.StartInfo.FileName = Path.Combine(this.driverServicePath, this.driverServiceExecutableName);
this.driverServiceProcess.StartInfo.Arguments = this.CommandLineArguments;
Expand All @@ -283,6 +288,12 @@ public void Start()
}
}

/// <summary>
/// The browser options instance that corresponds to the driver service
/// </summary>
/// <returns></returns>
protected abstract DriverOptions GetDefaultDriverOptions();

/// <summary>
/// Releases all resources associated with this <see cref="DriverService"/>.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions dotnet/src/webdriver/Edge/EdgeDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ private EdgeDriverService(string executablePath, string executableFileName, int
{
}

/// <inheritdoc />
protected override DriverOptions GetDefaultDriverOptions()
{
return new EdgeOptions();
}

/// <summary>
/// Gets or sets a value indicating whether the service should use verbose logging.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions dotnet/src/webdriver/Firefox/FirefoxDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ private FirefoxDriverService(string executablePath, string executableFileName, i
{
}

/// <inheritdoc />
protected override DriverOptions GetDefaultDriverOptions()
{
return new FirefoxOptions();
}

/// <summary>
/// Gets or sets the location of the Firefox binary executable.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions dotnet/src/webdriver/IE/InternetExplorerDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ private InternetExplorerDriverService(string executablePath, string executableFi
{
}

/// <inheritdoc />
protected override DriverOptions GetDefaultDriverOptions()
{
return new InternetExplorerOptions();
}

/// <summary>
/// Gets or sets the value of the host adapter on which the IEDriverServer should listen for connections.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions dotnet/src/webdriver/Safari/SafariDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ private SafariDriverService(string executablePath, string executableFileName, in
{
}

/// <inheritdoc />
protected override DriverOptions GetDefaultDriverOptions()
{
return new SafariOptions();
}

/// <summary>
/// Gets or sets a value indicating whether to use the default open-source project
/// dialect of the protocol instead of the default dialect compliant with the
Expand Down

0 comments on commit e66fbf5

Please sign in to comment.