[dotnet] explicitly support passing the full path to driver in Service constructor
diff --git a/dotnet/src/webdriver/Chrome/ChromeDriverService.cs b/dotnet/src/webdriver/Chrome/ChromeDriverService.cs index 20e2e1d..4c48017 100644 --- a/dotnet/src/webdriver/Chrome/ChromeDriverService.cs +++ b/dotnet/src/webdriver/Chrome/ChromeDriverService.cs
@@ -59,16 +59,22 @@ /// <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>
diff --git a/dotnet/src/webdriver/Edge/EdgeDriverService.cs b/dotnet/src/webdriver/Edge/EdgeDriverService.cs index e917b23..3e150e8 100644 --- a/dotnet/src/webdriver/Edge/EdgeDriverService.cs +++ b/dotnet/src/webdriver/Edge/EdgeDriverService.cs
@@ -73,12 +73,18 @@ /// <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>
diff --git a/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs b/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs index d6a8fa7..ce03981 100644 --- a/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs +++ b/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs
@@ -221,16 +221,22 @@ /// <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>
diff --git a/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs b/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs index 187890e..3a02b9c 100644 --- a/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs +++ b/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs
@@ -161,16 +161,22 @@ /// <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>
diff --git a/dotnet/src/webdriver/Safari/SafariDriverService.cs b/dotnet/src/webdriver/Safari/SafariDriverService.cs index 03fda32..10a77dd 100644 --- a/dotnet/src/webdriver/Safari/SafariDriverService.cs +++ b/dotnet/src/webdriver/Safari/SafariDriverService.cs
@@ -154,16 +154,22 @@ /// <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>