Skip to content

Commit

Permalink
[dotnet] explicitly support passing the full path to driver in Servic…
Browse files Browse the repository at this point in the history
…e constructor
  • Loading branch information
titusfortner committed Jan 30, 2024
1 parent b383138 commit 6dc4d57
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
10 changes: 8 additions & 2 deletions dotnet/src/webdriver/Chrome/ChromeDriverService.cs
Expand Up @@ -59,16 +59,22 @@ public static ChromeDriverService CreateDefaultService()
/// <summary>
/// Creates a default instance of the ChromeDriverService using a specified path to the ChromeDriver executable.
/// </summary>
/// <param name="driverPath">The directory containing the ChromeDriver executable.</param>
/// <param name="driverPath">The path to the executable or the directory containing the ChromeDriver executable.</param>
/// <returns>A ChromeDriverService using a random port.</returns>
public static ChromeDriverService CreateDefaultService(string driverPath)
{
string fileName;
if (File.Exists(driverPath))
{
fileName = Path.GetFileName(driverPath);
driverPath = Path.GetDirectoryName(driverPath);
}
else
{
fileName = ChromiumDriverServiceFileName(DefaultChromeDriverServiceExecutableName);
}

return CreateDefaultService(driverPath, ChromiumDriverServiceFileName(DefaultChromeDriverServiceExecutableName));
return CreateDefaultService(driverPath, fileName);
}

/// <summary>
Expand Down
8 changes: 7 additions & 1 deletion dotnet/src/webdriver/Edge/EdgeDriverService.cs
Expand Up @@ -73,12 +73,18 @@ public static EdgeDriverService CreateDefaultService()
/// <returns>An EdgeDriverService using a random port.</returns>
public static EdgeDriverService CreateDefaultService(string driverPath)
{
string fileName;
if (File.Exists(driverPath))
{
fileName = Path.GetFileName(driverPath);
driverPath = Path.GetDirectoryName(driverPath);
}
else
{
fileName = ChromiumDriverServiceFileName(MSEdgeDriverServiceFileName);
}

return CreateDefaultService(driverPath, ChromiumDriverServiceFileName(MSEdgeDriverServiceFileName));
return CreateDefaultService(driverPath, fileName);
}

/// <summary>
Expand Down
10 changes: 8 additions & 2 deletions dotnet/src/webdriver/Firefox/FirefoxDriverService.cs
Expand Up @@ -221,16 +221,22 @@ public static FirefoxDriverService CreateDefaultService()
/// <summary>
/// Creates a default instance of the FirefoxDriverService using a specified path to the Firefox driver executable.
/// </summary>
/// <param name="driverPath">The directory containing the Firefox driver executable.</param>
/// <param name="driverPath">The path to the executable or the directory containing the Firefox driver executable.</param>
/// <returns>A FirefoxDriverService using a random port.</returns>
public static FirefoxDriverService CreateDefaultService(string driverPath)
{
string fileName;
if (File.Exists(driverPath))
{
fileName = Path.GetFileName(driverPath);
driverPath = Path.GetDirectoryName(driverPath);
}
else
{
fileName = FirefoxDriverServiceFileName();
}

return CreateDefaultService(driverPath, FirefoxDriverServiceFileName());
return CreateDefaultService(driverPath, fileName);
}

/// <summary>
Expand Down
10 changes: 8 additions & 2 deletions dotnet/src/webdriver/IE/InternetExplorerDriverService.cs
Expand Up @@ -161,16 +161,22 @@ public static InternetExplorerDriverService CreateDefaultService()
/// <summary>
/// Creates a default instance of the InternetExplorerDriverService using a specified path to the IEDriverServer executable.
/// </summary>
/// <param name="driverPath">The directory containing the IEDriverServer executable.</param>
/// <param name="driverPath">The path to the executable or the directory containing the IEDriverServer executable.</param>
/// <returns>A InternetExplorerDriverService using a random port.</returns>
public static InternetExplorerDriverService CreateDefaultService(string driverPath)
{
string fileName;
if (File.Exists(driverPath))
{
fileName = Path.GetFileName(driverPath);
driverPath = Path.GetDirectoryName(driverPath);
}
else
{
fileName = InternetExplorerDriverServiceFileName;
}

return CreateDefaultService(driverPath, InternetExplorerDriverServiceFileName);
return CreateDefaultService(driverPath, fileName);
}

/// <summary>
Expand Down
10 changes: 8 additions & 2 deletions dotnet/src/webdriver/Safari/SafariDriverService.cs
Expand Up @@ -154,16 +154,22 @@ public static SafariDriverService CreateDefaultService()
/// <summary>
/// Creates a default instance of the SafariDriverService using a specified path to the SafariDriver executable.
/// </summary>
/// <param name="driverPath">The directory containing the SafariDriver executable.</param>
/// <param name="driverPath">The path to the executable or the directory containing the SafariDriver executable.</param>
/// <returns>A SafariDriverService using a random port.</returns>
public static SafariDriverService CreateDefaultService(string driverPath)
{
string fileName;
if (File.Exists(driverPath))
{
fileName = Path.GetFileName(driverPath);
driverPath = Path.GetDirectoryName(driverPath);
}
else
{
fileName = DefaultSafariDriverServiceExecutableName;
}

return CreateDefaultService(driverPath, DefaultSafariDriverServiceExecutableName);
return CreateDefaultService(driverPath, fileName);
}

/// <summary>
Expand Down

0 comments on commit 6dc4d57

Please sign in to comment.