Skip to content

Commit 62716d5

Browse files
committed
Revert "Fix tests execution, but service is still not disposed yet"
This reverts commit 57b3a69.
1 parent 57b3a69 commit 62716d5

13 files changed

+87
-56
lines changed

dotnet/src/webdriver/Chrome/ChromeDriver.cs

Lines changed: 14 additions & 3 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)
128+
: this(ChromeDriverService.CreateDefaultService(chromeDriverDirectory), options, commandTimeout, disposeService: true)
129129
{
130130
}
131131

@@ -136,7 +136,12 @@ 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)
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)
140145
{
141146
}
142147

@@ -147,7 +152,13 @@ public ChromeDriver(ChromeDriverService service, ChromeOptions options)
147152
/// <param name="options">The <see cref="ChromeOptions"/> to be used with the Chrome driver.</param>
148153
/// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
149154
public ChromeDriver(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
150-
: base(service, options, 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)
151162
{
152163
this.AddCustomChromeCommands();
153164
}

dotnet/src/webdriver/Chromium/ChromiumDriver.cs

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

109109
private readonly ChromiumDriverService driverService;
110+
private readonly bool disposeDriverService;
110111
private readonly string optionsCapabilityName;
111112
private DevToolsSession devToolsSession;
112113

@@ -127,10 +128,11 @@ public class ChromiumDriver : WebDriver, ISupportsLogs, IDevTools
127128
/// <param name="service">The <see cref="ChromiumDriverService"/> to use.</param>
128129
/// <param name="options">The <see cref="ChromiumOptions"/> to be used with the ChromiumDriver.</param>
129130
/// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
130-
protected ChromiumDriver(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
131+
protected ChromiumDriver(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout, bool disposeService)
131132
: base(StartDriverServiceCommandExecutor(service, options, commandTimeout), ConvertOptionsToCapabilities(options))
132133
{
133134
this.driverService = service;
135+
this.disposeDriverService = disposeService;
134136
this.optionsCapabilityName = options.CapabilityName;
135137
}
136138

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

471473
base.Dispose(disposing);
474+
475+
if (this.disposeDriverService)
476+
{
477+
this.driverService?.Dispose();
478+
}
472479
}
473480

474481
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)
120+
: base(service, options, commandTimeout, disposeService: false)
121121
{
122122
this.AddCustomEdgeCommands();
123123
}

dotnet/test/common/CustomDriverConfigs/DefaultSafariDriver.cs

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

14-
public DefaultSafariDriver(SafariDriverService service)
15-
: base(service)
16-
{
17-
}
18-
1914
public DefaultSafariDriver(SafariDriverService service, SafariOptions options)
2015
: base(service, options)
2116
{

dotnet/test/common/CustomDriverConfigs/DevChannelChromeDriver.cs

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

16-
public DevChannelChromeDriver(ChromeDriverService service)
17-
: base(service)
18-
{
19-
}
20-
2116
public DevChannelChromeDriver(ChromeDriverService service, ChromeOptions options)
2217
: base(service, options)
2318
{

dotnet/test/common/CustomDriverConfigs/DevChannelEdgeDriver.cs

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

16-
public DevChannelEdgeDriver(EdgeDriverService service)
17-
: base(service)
18-
{
19-
}
20-
2116
public DevChannelEdgeDriver(EdgeDriverService service, EdgeOptions options)
2217
: base(service, options)
2318
{

dotnet/test/common/CustomDriverConfigs/EdgeInternetExplorerModeDriver.cs

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

19-
public EdgeInternetExplorerModeDriver(InternetExplorerDriverService service)
20-
: base(service)
21-
{
22-
}
23-
2419
public EdgeInternetExplorerModeDriver(InternetExplorerDriverService service, InternetExplorerOptions options)
2520
: base(service, options)
2621
{

dotnet/test/common/CustomDriverConfigs/NightlyChannelFirefoxDriver.cs

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

19-
public NightlyChannelFirefoxDriver(FirefoxDriverService service)
20-
: base(service)
21-
{
22-
}
23-
2419
public NightlyChannelFirefoxDriver(FirefoxDriverService service, FirefoxOptions options)
2520
: base(service, options)
2621
{

dotnet/test/common/CustomDriverConfigs/SafariTechnologyPreviewDriver.cs

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

19-
public SafariTechnologyPreviewDriver(SafariDriverService service)
20-
: base(service)
21-
{
22-
}
23-
2419
public SafariTechnologyPreviewDriver(SafariDriverService service, SafariOptions options)
2520
: base(service, options)
2621
{

dotnet/test/common/CustomDriverConfigs/StableChannelChromeDriver.cs

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

16-
public StableChannelChromeDriver(ChromeDriverService service)
17-
: base(service)
18-
{
19-
}
20-
2116
public StableChannelChromeDriver(ChromeDriverService service, ChromeOptions options)
2217
: base(service, options)
2318
{

0 commit comments

Comments
 (0)