Skip to content

Commit 0ce64cb

Browse files
authored
[dotnet] Using SM in default service creation (#11994)
* [dotnet] Using SM in default service creation * Skipping two tests due to Chrome bug
1 parent de7acb9 commit 0ce64cb

10 files changed

Lines changed: 56 additions & 11 deletions

dotnet/src/webdriver/Chrome/ChromeDriver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public ChromeDriver()
8383
/// </summary>
8484
/// <param name="options">The <see cref="ChromeOptions"/> to be used with the Chrome driver.</param>
8585
public ChromeDriver(ChromeOptions options)
86-
: this(ChromeDriverService.CreateDefaultService(), options, RemoteWebDriver.DefaultCommandTimeout)
86+
: this(ChromeDriverService.CreateDefaultService(options), options, RemoteWebDriver.DefaultCommandTimeout)
8787
{
8888
}
8989

dotnet/src/webdriver/Chrome/ChromeDriverService.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
// </copyright>
1818

1919
using System;
20-
using System.Globalization;
21-
using System.Text;
2220
using OpenQA.Selenium.Internal;
2321
using OpenQA.Selenium.Chromium;
2422

@@ -49,10 +47,21 @@ private ChromeDriverService(string executablePath, string executableFileName, in
4947
/// </summary>
5048
/// <returns>A ChromeDriverService that implements default settings.</returns>
5149
public static ChromeDriverService CreateDefaultService()
50+
{
51+
return CreateDefaultService(new ChromeOptions());
52+
}
53+
54+
/// <summary>
55+
/// Creates a default instance of the ChromeDriverService.
56+
/// </summary>
57+
/// /// <param name="options">Browser options used to find the correct ChromeDriver binary.</param>
58+
/// <returns>A ChromeDriverService that implements default settings.</returns>
59+
public static ChromeDriverService CreateDefaultService(ChromeOptions options)
5260
{
5361
string serviceDirectory = DriverService.FindDriverServiceExecutable(ChromiumDriverServiceFileName(DefaultChromeDriverServiceExecutableName),
5462
ChromeDriverDownloadUrl);
55-
return CreateDefaultService(serviceDirectory);
63+
ChromeDriverService service = CreateDefaultService(serviceDirectory);
64+
return DriverFinder.VerifyDriverServicePath(service, options) as ChromeDriverService;;
5665
}
5766

5867
/// <summary>

dotnet/src/webdriver/Edge/EdgeDriver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public EdgeDriver()
5353
/// </summary>
5454
/// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param>
5555
public EdgeDriver(EdgeOptions options)
56-
: this(EdgeDriverService.CreateDefaultService(), options)
56+
: this(EdgeDriverService.CreateDefaultService(options), options)
5757
{
5858
}
5959

dotnet/src/webdriver/Edge/EdgeDriverService.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,21 @@ public bool UseVerboseLogging
5858
/// </summary>
5959
/// <returns>A EdgeDriverService that implements default settings.</returns>
6060
public static EdgeDriverService CreateDefaultService()
61+
{
62+
return CreateDefaultService(new EdgeOptions());
63+
}
64+
65+
/// <summary>
66+
/// Creates a default instance of the EdgeDriverService.
67+
/// </summary>
68+
/// <param name="options">Browser options used to find the correct MSEdgeDriver binary.</param>
69+
/// <returns>A EdgeDriverService that implements default settings.</returns>
70+
public static EdgeDriverService CreateDefaultService(EdgeOptions options)
6171
{
6272
string serviceDirectory = DriverService.FindDriverServiceExecutable(ChromiumDriverServiceFileName(MSEdgeDriverServiceFileName),
63-
MicrosoftWebDriverDownloadUrl);
64-
return CreateDefaultService(serviceDirectory);
73+
MicrosoftWebDriverDownloadUrl);
74+
EdgeDriverService service = CreateDefaultService(serviceDirectory);
75+
return DriverFinder.VerifyDriverServicePath(service, options) as EdgeDriverService;
6576
}
6677

6778
/// <summary>

dotnet/src/webdriver/Firefox/FirefoxDriver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ private static ICapabilities ConvertOptionsToCapabilities(FirefoxOptions options
436436

437437
private static FirefoxDriverService CreateService(FirefoxOptions options)
438438
{
439-
return FirefoxDriverService.CreateDefaultService();
439+
return FirefoxDriverService.CreateDefaultService(options);
440440
}
441441

442442
private void AddCustomFirefoxCommands()

dotnet/src/webdriver/Firefox/FirefoxDriverService.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,21 @@ protected override string CommandLineArguments
208208
/// </summary>
209209
/// <returns>A FirefoxDriverService that implements default settings.</returns>
210210
public static FirefoxDriverService CreateDefaultService()
211+
{
212+
return CreateDefaultService(new FirefoxOptions());
213+
}
214+
215+
216+
/// <summary>
217+
/// Creates a default instance of the FirefoxDriverService.
218+
/// </summary>
219+
/// <param name="options">Browser options used to find the correct GeckoDriver binary.</param>
220+
/// <returns>A FirefoxDriverService that implements default settings.</returns>
221+
public static FirefoxDriverService CreateDefaultService(FirefoxOptions options)
211222
{
212223
string serviceDirectory = DriverService.FindDriverServiceExecutable(FirefoxDriverServiceFileName(), FirefoxDriverDownloadUrl);
213-
return CreateDefaultService(serviceDirectory);
224+
FirefoxDriverService service = CreateDefaultService(serviceDirectory);
225+
return DriverFinder.VerifyDriverServicePath(service, options) as FirefoxDriverService;
214226
}
215227

216228
/// <summary>

dotnet/src/webdriver/IE/InternetExplorerDriver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public InternetExplorerDriver()
7575
/// </summary>
7676
/// <param name="options">The <see cref="InternetExplorerOptions"/> used to initialize the driver.</param>
7777
public InternetExplorerDriver(InternetExplorerOptions options)
78-
: this(InternetExplorerDriverService.CreateDefaultService(), options)
78+
: this(InternetExplorerDriverService.CreateDefaultService(options), options)
7979
{
8080
}
8181

dotnet/src/webdriver/IE/InternetExplorerDriverService.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,20 @@ protected override string CommandLineArguments
148148
/// </summary>
149149
/// <returns>A InternetExplorerDriverService that implements default settings.</returns>
150150
public static InternetExplorerDriverService CreateDefaultService()
151+
{
152+
return CreateDefaultService(new InternetExplorerOptions());
153+
}
154+
155+
/// <summary>
156+
/// Creates a default instance of the InternetExplorerDriverService.
157+
/// </summary>
158+
/// <param name="options">Browser options used to find the correct IEDriver binary.</param>
159+
/// <returns>A InternetExplorerDriverService that implements default settings.</returns>
160+
public static InternetExplorerDriverService CreateDefaultService(InternetExplorerOptions options)
151161
{
152162
string serviceDirectory = DriverService.FindDriverServiceExecutable(InternetExplorerDriverServiceFileName, InternetExplorerDriverDownloadUrl);
153-
return CreateDefaultService(serviceDirectory);
163+
InternetExplorerDriverService service = CreateDefaultService(serviceDirectory);
164+
return DriverFinder.VerifyDriverServicePath(service, options) as InternetExplorerDriverService;
154165
}
155166

156167
/// <summary>

dotnet/test/common/ElementEqualityTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public void SameElementLookedUpDifferentWaysUsingFindElementsShouldHaveSameHashC
4848
}
4949

5050
[Test]
51+
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4443")]
5152
public void AnElementFoundInADifferentFrameViaJsShouldHaveSameId()
5253
{
5354
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("missedJsReference.html");

dotnet/test/common/ElementFindingTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ public void AnElementFoundInADifferentFrameIsStale()
811811
}
812812

813813
[Test]
814+
[IgnoreBrowser(Browser.Chrome, "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4443")]
814815
public void AnElementFoundInADifferentFrameViaJsCanBeUsed()
815816
{
816817
driver.Url = missedJsReferencePage;

0 commit comments

Comments
 (0)