Skip to content

Commit 912bc7e

Browse files
committed
Merge branch 'dotnet-reusable-driverservice' of https://github.com/nvborisenko/selenium-hq into dotnet-reusable-driverservice
2 parents 62716d5 + aff5b83 commit 912bc7e

13 files changed

+56
-87
lines changed

dotnet/src/webdriver/Chrome/ChromeDriver.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public ChromeDriver(string chromeDriverDirectory, ChromeOptions options)
125125
/// <param name="options">The <see cref="ChromeOptions"/> to be used with the Chrome driver.</param>
126126
/// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
127127
public ChromeDriver(string chromeDriverDirectory, ChromeOptions options, TimeSpan commandTimeout)
128-
: this(ChromeDriverService.CreateDefaultService(chromeDriverDirectory), options, commandTimeout, disposeService: true)
128+
: this(ChromeDriverService.CreateDefaultService(chromeDriverDirectory), options, commandTimeout)
129129
{
130130
}
131131

@@ -136,12 +136,7 @@ public ChromeDriver(string chromeDriverDirectory, ChromeOptions options, TimeSpa
136136
/// <param name="service">The <see cref="ChromeDriverService"/> to use.</param>
137137
/// <param name="options">The <see cref="ChromeOptions"/> used to initialize the driver.</param>
138138
public ChromeDriver(ChromeDriverService service, ChromeOptions options)
139-
: this(service, options, RemoteWebDriver.DefaultCommandTimeout, disposeService: true)
140-
{
141-
}
142-
143-
public ChromeDriver(ChromeDriverService service, ChromeOptions options, bool disposeService)
144-
: this(service, options, RemoteWebDriver.DefaultCommandTimeout, disposeService)
139+
: this(service, options, RemoteWebDriver.DefaultCommandTimeout)
145140
{
146141
}
147142

@@ -152,13 +147,7 @@ public ChromeDriver(ChromeDriverService service, ChromeOptions options, bool dis
152147
/// <param name="options">The <see cref="ChromeOptions"/> to be used with the Chrome driver.</param>
153148
/// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
154149
public ChromeDriver(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
155-
: base(service, options, commandTimeout, disposeService: true)
156-
{
157-
this.AddCustomChromeCommands();
158-
}
159-
160-
public ChromeDriver(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout, bool disposeService)
161-
: base(service, options, commandTimeout, disposeService)
150+
: base(service, options, commandTimeout)
162151
{
163152
this.AddCustomChromeCommands();
164153
}

dotnet/src/webdriver/Chromium/ChromiumDriver.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ public class ChromiumDriver : WebDriver, ISupportsLogs, IDevTools
107107
public static readonly string SetPermissionCommand = "setPermission";
108108

109109
private readonly ChromiumDriverService driverService;
110-
private readonly bool disposeDriverService;
111110
private readonly string optionsCapabilityName;
112111
private DevToolsSession devToolsSession;
113112

@@ -128,11 +127,10 @@ public class ChromiumDriver : WebDriver, ISupportsLogs, IDevTools
128127
/// <param name="service">The <see cref="ChromiumDriverService"/> to use.</param>
129128
/// <param name="options">The <see cref="ChromiumOptions"/> to be used with the ChromiumDriver.</param>
130129
/// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
131-
protected ChromiumDriver(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout, bool disposeService)
130+
protected ChromiumDriver(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
132131
: base(StartDriverServiceCommandExecutor(service, options, commandTimeout), ConvertOptionsToCapabilities(options))
133132
{
134133
this.driverService = service;
135-
this.disposeDriverService = disposeService;
136134
this.optionsCapabilityName = options.CapabilityName;
137135
}
138136

@@ -471,11 +469,6 @@ protected override void Dispose(bool disposing)
471469
}
472470

473471
base.Dispose(disposing);
474-
475-
if (this.disposeDriverService)
476-
{
477-
this.driverService?.Dispose();
478-
}
479472
}
480473

481474
private static ICapabilities ConvertOptionsToCapabilities(ChromiumOptions options)

dotnet/src/webdriver/Edge/EdgeDriver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public EdgeDriver(EdgeDriverService service, EdgeOptions options)
117117
/// <param name="options">The <see cref="EdgeOptions"/> to be used with the Edge driver.</param>
118118
/// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
119119
public EdgeDriver(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout)
120-
: base(service, options, commandTimeout, disposeService: false)
120+
: base(service, options, commandTimeout)
121121
{
122122
this.AddCustomEdgeCommands();
123123
}

dotnet/test/common/CustomDriverConfigs/DefaultSafariDriver.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ public DefaultSafariDriver(SafariOptions options)
1111
{
1212
}
1313

14+
public DefaultSafariDriver(SafariDriverService service)
15+
: base(service)
16+
{
17+
}
18+
1419
public DefaultSafariDriver(SafariDriverService service, SafariOptions options)
1520
: base(service, options)
1621
{

dotnet/test/common/CustomDriverConfigs/DevChannelChromeDriver.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public DevChannelChromeDriver(ChromeOptions options)
1313
{
1414
}
1515

16+
public DevChannelChromeDriver(ChromeDriverService service)
17+
: base(service)
18+
{
19+
}
20+
1621
public DevChannelChromeDriver(ChromeDriverService service, ChromeOptions options)
1722
: base(service, options)
1823
{

dotnet/test/common/CustomDriverConfigs/DevChannelEdgeDriver.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public DevChannelEdgeDriver(EdgeOptions options)
1313
{
1414
}
1515

16+
public DevChannelEdgeDriver(EdgeDriverService service)
17+
: base(service)
18+
{
19+
}
20+
1621
public DevChannelEdgeDriver(EdgeDriverService service, EdgeOptions options)
1722
: base(service, options)
1823
{

dotnet/test/common/CustomDriverConfigs/EdgeInternetExplorerModeDriver.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public EdgeInternetExplorerModeDriver(InternetExplorerOptions options)
1616
{
1717
}
1818

19+
public EdgeInternetExplorerModeDriver(InternetExplorerDriverService service)
20+
: base(service)
21+
{
22+
}
23+
1924
public EdgeInternetExplorerModeDriver(InternetExplorerDriverService service, InternetExplorerOptions options)
2025
: base(service, options)
2126
{

dotnet/test/common/CustomDriverConfigs/NightlyChannelFirefoxDriver.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public NightlyChannelFirefoxDriver(FirefoxOptions options)
1616
{
1717
}
1818

19+
public NightlyChannelFirefoxDriver(FirefoxDriverService service)
20+
: base(service)
21+
{
22+
}
23+
1924
public NightlyChannelFirefoxDriver(FirefoxDriverService service, FirefoxOptions options)
2025
: base(service, options)
2126
{

dotnet/test/common/CustomDriverConfigs/SafariTechnologyPreviewDriver.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public SafariTechnologyPreviewDriver(SafariOptions options)
1616
{
1717
}
1818

19+
public SafariTechnologyPreviewDriver(SafariDriverService service)
20+
: base(service)
21+
{
22+
}
23+
1924
public SafariTechnologyPreviewDriver(SafariDriverService service, SafariOptions options)
2025
: base(service, options)
2126
{

dotnet/test/common/CustomDriverConfigs/StableChannelChromeDriver.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public StableChannelChromeDriver(ChromeOptions options)
1313
{
1414
}
1515

16+
public StableChannelChromeDriver(ChromeDriverService service)
17+
: base(service)
18+
{
19+
}
20+
1621
public StableChannelChromeDriver(ChromeDriverService service, ChromeOptions options)
1722
: base(service, options)
1823
{

0 commit comments

Comments
 (0)