From 65841e5fb681dbb8c7b9efea87640e038a995d6d Mon Sep 17 00:00:00 2001 From: Michael Render Date: Mon, 24 Feb 2025 15:06:49 -0500 Subject: [PATCH 1/3] [dotnet] Do not warn when passing in null driver paths to driver service --- dotnet/src/webdriver/Chrome/ChromeDriverService.cs | 4 ++-- dotnet/src/webdriver/Edge/EdgeDriverService.cs | 4 ++-- dotnet/src/webdriver/Firefox/FirefoxDriverService.cs | 4 ++-- dotnet/src/webdriver/IE/InternetExplorerDriverService.cs | 4 ++-- dotnet/src/webdriver/Safari/SafariDriverService.cs | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dotnet/src/webdriver/Chrome/ChromeDriverService.cs b/dotnet/src/webdriver/Chrome/ChromeDriverService.cs index ee1a2559a77e9..97750c6813323 100644 --- a/dotnet/src/webdriver/Chrome/ChromeDriverService.cs +++ b/dotnet/src/webdriver/Chrome/ChromeDriverService.cs @@ -63,7 +63,7 @@ public static ChromeDriverService CreateDefaultService() /// /// The path to the executable or the directory containing the ChromeDriver executable. /// A ChromeDriverService using a random port. - public static ChromeDriverService CreateDefaultService(string driverPath) + public static ChromeDriverService CreateDefaultService(string? driverPath) { string fileName; if (File.Exists(driverPath)) @@ -85,7 +85,7 @@ public static ChromeDriverService CreateDefaultService(string driverPath) /// The directory containing the ChromeDriver executable. /// The name of the ChromeDriver executable file. /// A ChromeDriverService using a random port. - public static ChromeDriverService CreateDefaultService(string driverPath, string driverExecutableFileName) + public static ChromeDriverService CreateDefaultService(string? driverPath, string? driverExecutableFileName) { return new ChromeDriverService(driverPath, driverExecutableFileName, PortUtilities.FindFreePort()); } diff --git a/dotnet/src/webdriver/Edge/EdgeDriverService.cs b/dotnet/src/webdriver/Edge/EdgeDriverService.cs index 4a911439c8dbd..68e40781dd703 100644 --- a/dotnet/src/webdriver/Edge/EdgeDriverService.cs +++ b/dotnet/src/webdriver/Edge/EdgeDriverService.cs @@ -74,7 +74,7 @@ public static EdgeDriverService CreateDefaultService() /// /// The directory containing the EdgeDriver executable. /// An EdgeDriverService using a random port. - public static EdgeDriverService CreateDefaultService(string driverPath) + public static EdgeDriverService CreateDefaultService(string? driverPath) { string fileName; if (File.Exists(driverPath)) @@ -96,7 +96,7 @@ public static EdgeDriverService CreateDefaultService(string driverPath) /// The directory containing the EdgeDriver executable. /// The name of the EdgeDriver executable file. /// A EdgeDriverService using a random port. - public static EdgeDriverService CreateDefaultService(string driverPath, string driverExecutableFileName) + public static EdgeDriverService CreateDefaultService(string? driverPath, string? driverExecutableFileName) { return new EdgeDriverService(driverPath, driverExecutableFileName, PortUtilities.FindFreePort()); } diff --git a/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs b/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs index a7cf0cec88bcd..ffcffed5ba508 100644 --- a/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs +++ b/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs @@ -194,7 +194,7 @@ public static FirefoxDriverService CreateDefaultService() /// /// The path to the executable or the directory containing the Firefox driver executable. /// A FirefoxDriverService using a random port. - public static FirefoxDriverService CreateDefaultService(string driverPath) + public static FirefoxDriverService CreateDefaultService(string? driverPath) { string fileName; if (File.Exists(driverPath)) @@ -216,7 +216,7 @@ public static FirefoxDriverService CreateDefaultService(string driverPath) /// The directory containing the Firefox driver executable. /// The name of the Firefox driver executable file. /// A FirefoxDriverService using a random port. - public static FirefoxDriverService CreateDefaultService(string driverPath, string driverExecutableFileName) + public static FirefoxDriverService CreateDefaultService(string? driverPath, string? driverExecutableFileName) { return new FirefoxDriverService(driverPath, driverExecutableFileName, PortUtilities.FindFreePort()); } diff --git a/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs b/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs index 9b7af524877a7..1b1484b8010f3 100644 --- a/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs +++ b/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs @@ -138,7 +138,7 @@ public static InternetExplorerDriverService CreateDefaultService() /// /// The path to the executable or the directory containing the IEDriverServer executable. /// A InternetExplorerDriverService using a random port. - public static InternetExplorerDriverService CreateDefaultService(string driverPath) + public static InternetExplorerDriverService CreateDefaultService(string? driverPath) { string fileName; if (File.Exists(driverPath)) @@ -160,7 +160,7 @@ public static InternetExplorerDriverService CreateDefaultService(string driverPa /// The directory containing the IEDriverServer executable. /// The name of the IEDriverServer executable file. /// A InternetExplorerDriverService using a random port. - public static InternetExplorerDriverService CreateDefaultService(string driverPath, string driverExecutableFileName) + public static InternetExplorerDriverService CreateDefaultService(string? driverPath, string? driverExecutableFileName) { return new InternetExplorerDriverService(driverPath, driverExecutableFileName, PortUtilities.FindFreePort()); } diff --git a/dotnet/src/webdriver/Safari/SafariDriverService.cs b/dotnet/src/webdriver/Safari/SafariDriverService.cs index b3ee30a85ddd7..d7028b1f1127c 100644 --- a/dotnet/src/webdriver/Safari/SafariDriverService.cs +++ b/dotnet/src/webdriver/Safari/SafariDriverService.cs @@ -103,7 +103,7 @@ public static SafariDriverService CreateDefaultService() /// /// The path to the executable or the directory containing the SafariDriver executable. /// A SafariDriverService using a random port. - public static SafariDriverService CreateDefaultService(string driverPath) + public static SafariDriverService CreateDefaultService(string? driverPath) { string fileName; if (File.Exists(driverPath)) @@ -125,7 +125,7 @@ public static SafariDriverService CreateDefaultService(string driverPath) /// The directory containing the SafariDriver executable. /// The name of the SafariDriver executable file. /// A SafariDriverService using a random port. - public static SafariDriverService CreateDefaultService(string driverPath, string driverExecutableFileName) + public static SafariDriverService CreateDefaultService(string? driverPath, string? driverExecutableFileName) { return new SafariDriverService(driverPath, driverExecutableFileName, PortUtilities.FindFreePort()); } From 595ec82df8f99166f8b9e89faa92edd9a05f31a3 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Mon, 24 Feb 2025 23:29:05 -0500 Subject: [PATCH 2/3] Clarify functionality of CreateDriverService --- dotnet/src/webdriver/Chrome/ChromeDriverService.cs | 14 ++++++++------ dotnet/src/webdriver/Edge/EdgeDriverService.cs | 14 ++++++++------ .../src/webdriver/Firefox/FirefoxDriverService.cs | 14 ++++++++------ .../webdriver/IE/InternetExplorerDriverService.cs | 14 ++++++++------ dotnet/src/webdriver/Safari/SafariDriverService.cs | 14 ++++++++------ 5 files changed, 40 insertions(+), 30 deletions(-) diff --git a/dotnet/src/webdriver/Chrome/ChromeDriverService.cs b/dotnet/src/webdriver/Chrome/ChromeDriverService.cs index 97750c6813323..e1b5c3f23ccfa 100644 --- a/dotnet/src/webdriver/Chrome/ChromeDriverService.cs +++ b/dotnet/src/webdriver/Chrome/ChromeDriverService.cs @@ -65,18 +65,20 @@ public static ChromeDriverService CreateDefaultService() /// A ChromeDriverService using a random port. public static ChromeDriverService CreateDefaultService(string? driverPath) { - string fileName; if (File.Exists(driverPath)) { - fileName = Path.GetFileName(driverPath); - driverPath = Path.GetDirectoryName(driverPath)!; + string fileName = Path.GetFileName(driverPath); + string driverFolder = Path.GetDirectoryName(driverPath)!; + + return CreateDefaultService(driverFolder, fileName); } else { - fileName = ChromiumDriverServiceFileName(DefaultChromeDriverServiceExecutableName); - } + string fileName = ChromiumDriverServiceFileName(DefaultChromeDriverServiceExecutableName); + string? driverFolder = driverPath; - return CreateDefaultService(driverPath, fileName); + return CreateDefaultService(driverFolder, fileName); + } } /// diff --git a/dotnet/src/webdriver/Edge/EdgeDriverService.cs b/dotnet/src/webdriver/Edge/EdgeDriverService.cs index 68e40781dd703..93d08fd7df2d1 100644 --- a/dotnet/src/webdriver/Edge/EdgeDriverService.cs +++ b/dotnet/src/webdriver/Edge/EdgeDriverService.cs @@ -76,18 +76,20 @@ public static EdgeDriverService CreateDefaultService() /// An EdgeDriverService using a random port. public static EdgeDriverService CreateDefaultService(string? driverPath) { - string fileName; if (File.Exists(driverPath)) { - fileName = Path.GetFileName(driverPath); - driverPath = Path.GetDirectoryName(driverPath)!; + string fileName = Path.GetFileName(driverPath); + string driverFolder = Path.GetDirectoryName(driverPath)!; + + return CreateDefaultService(driverFolder, fileName); } else { - fileName = ChromiumDriverServiceFileName(MSEdgeDriverServiceFileName); - } + string fileName = ChromiumDriverServiceFileName(MSEdgeDriverServiceFileName); + string? driverFolder = driverPath; - return CreateDefaultService(driverPath, fileName); + return CreateDefaultService(driverFolder, fileName); + } } /// diff --git a/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs b/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs index ffcffed5ba508..f53fd5640d416 100644 --- a/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs +++ b/dotnet/src/webdriver/Firefox/FirefoxDriverService.cs @@ -196,18 +196,20 @@ public static FirefoxDriverService CreateDefaultService() /// A FirefoxDriverService using a random port. public static FirefoxDriverService CreateDefaultService(string? driverPath) { - string fileName; if (File.Exists(driverPath)) { - fileName = Path.GetFileName(driverPath); - driverPath = Path.GetDirectoryName(driverPath)!; + string fileName = Path.GetFileName(driverPath); + string driverFolder = Path.GetDirectoryName(driverPath)!; + + return CreateDefaultService(driverFolder, fileName); } else { - fileName = FirefoxDriverServiceFileName(); - } + string fileName = FirefoxDriverServiceFileName(); + string? driverFolder = driverPath; - return CreateDefaultService(driverPath, fileName); + return CreateDefaultService(driverFolder, fileName); + } } /// diff --git a/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs b/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs index 1b1484b8010f3..19dca45dabb44 100644 --- a/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs +++ b/dotnet/src/webdriver/IE/InternetExplorerDriverService.cs @@ -140,18 +140,20 @@ public static InternetExplorerDriverService CreateDefaultService() /// A InternetExplorerDriverService using a random port. public static InternetExplorerDriverService CreateDefaultService(string? driverPath) { - string fileName; if (File.Exists(driverPath)) { - fileName = Path.GetFileName(driverPath); - driverPath = Path.GetDirectoryName(driverPath)!; + string fileName = Path.GetFileName(driverPath); + string driverFolder = Path.GetDirectoryName(driverPath)!; + + return CreateDefaultService(driverFolder, fileName); } else { - fileName = InternetExplorerDriverServiceFileName; - } + string fileName = InternetExplorerDriverServiceFileName; + string? driverFolder = driverPath; - return CreateDefaultService(driverPath, fileName); + return CreateDefaultService(driverFolder, fileName); + } } /// diff --git a/dotnet/src/webdriver/Safari/SafariDriverService.cs b/dotnet/src/webdriver/Safari/SafariDriverService.cs index d7028b1f1127c..92e2ddb742bff 100644 --- a/dotnet/src/webdriver/Safari/SafariDriverService.cs +++ b/dotnet/src/webdriver/Safari/SafariDriverService.cs @@ -105,18 +105,20 @@ public static SafariDriverService CreateDefaultService() /// A SafariDriverService using a random port. public static SafariDriverService CreateDefaultService(string? driverPath) { - string fileName; if (File.Exists(driverPath)) { - fileName = Path.GetFileName(driverPath); - driverPath = Path.GetDirectoryName(driverPath)!; + string fileName = Path.GetFileName(driverPath); + string driverFolder = Path.GetDirectoryName(driverPath)!; + + return CreateDefaultService(driverFolder, fileName); } else { - fileName = DefaultSafariDriverServiceExecutableName; - } + string fileName = DefaultSafariDriverServiceExecutableName; + string? driverFolder = driverPath; - return CreateDefaultService(driverPath, fileName); + return CreateDefaultService(driverFolder, fileName); + } } /// From b01b3f50f9e8fb0ecbe39df479c45a8cd233a8b3 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Mon, 24 Feb 2025 23:33:54 -0500 Subject: [PATCH 3/3] fix XML comment for `EdgeDriverService` --- dotnet/src/webdriver/Edge/EdgeDriverService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/src/webdriver/Edge/EdgeDriverService.cs b/dotnet/src/webdriver/Edge/EdgeDriverService.cs index 93d08fd7df2d1..feca473b8f10a 100644 --- a/dotnet/src/webdriver/Edge/EdgeDriverService.cs +++ b/dotnet/src/webdriver/Edge/EdgeDriverService.cs @@ -72,7 +72,7 @@ public static EdgeDriverService CreateDefaultService() /// /// Creates a default instance of the EdgeDriverService using a specified path to the EdgeDriver executable. /// - /// The directory containing the EdgeDriver executable. + /// The path to the executable or the directory containing the EdgeDriver executable. /// An EdgeDriverService using a random port. public static EdgeDriverService CreateDefaultService(string? driverPath) {