Skip to content

Commit 07861c5

Browse files
committed
Chromium and firefox are good
1 parent c1c48d1 commit 07861c5

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

dotnet/src/webdriver/Chromium/ChromiumDriver.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,13 @@ protected override void Dispose(bool disposing)
471471
this.devToolsSession = null;
472472
}
473473

474+
if (this.SessionId is not null)
475+
{
476+
this.Execute(DriverCommand.Quit, null);
477+
478+
this.SessionId = null;
479+
}
480+
474481
if (this.disposeDriverService)
475482
{
476483
this.driverService.Dispose();

dotnet/src/webdriver/Firefox/FirefoxDriver.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ public class FirefoxDriver : WebDriver, IDevTools
110110
{ GetFullPageScreenshotCommand, new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/moz/screenshot/full") }
111111
};
112112

113+
private FirefoxDriverService driverService;
114+
private bool disposeDriverService;
113115
private DevToolsSession devToolsSession;
114116

115117
/// <summary>
@@ -125,7 +127,7 @@ public FirefoxDriver()
125127
/// </summary>
126128
/// <param name="options">The <see cref="FirefoxOptions"/> to be used with the Firefox driver.</param>
127129
public FirefoxDriver(FirefoxOptions options)
128-
: this(FirefoxDriverService.CreateDefaultService(), options, RemoteWebDriver.DefaultCommandTimeout)
130+
: this(FirefoxDriverService.CreateDefaultService(), disposeService: true, options, RemoteWebDriver.DefaultCommandTimeout)
129131
{
130132
}
131133

@@ -167,7 +169,7 @@ public FirefoxDriver(string geckoDriverDirectory, FirefoxOptions options)
167169
/// <param name="options">The <see cref="FirefoxOptions"/> to be used with the Firefox driver.</param>
168170
/// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
169171
public FirefoxDriver(string geckoDriverDirectory, FirefoxOptions options, TimeSpan commandTimeout)
170-
: this(FirefoxDriverService.CreateDefaultService(geckoDriverDirectory), options, commandTimeout)
172+
: this(FirefoxDriverService.CreateDefaultService(geckoDriverDirectory), disposeService: true, options, commandTimeout)
171173
{
172174
}
173175

@@ -188,8 +190,17 @@ public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options)
188190
/// <param name="options">The <see cref="FirefoxOptions"/> to be used with the Firefox driver.</param>
189191
/// <param name="commandTimeout">The maximum amount of time to wait for each command.</param>
190192
public FirefoxDriver(FirefoxDriverService service, FirefoxOptions options, TimeSpan commandTimeout)
193+
: this(service, disposeService: false, options, commandTimeout)
194+
{
195+
196+
}
197+
198+
private FirefoxDriver(FirefoxDriverService service, bool disposeService, FirefoxOptions options, TimeSpan commandTimeout)
191199
: base(StartDriverServiceCommandExecutor(service, options, commandTimeout), ConvertOptionsToCapabilities(options))
192200
{
201+
this.driverService = service;
202+
this.disposeDriverService = disposeService;
203+
193204
// Add the custom commands unique to Firefox
194205
this.AddCustomFirefoxCommands();
195206
}
@@ -477,6 +488,19 @@ protected override void Dispose(bool disposing)
477488
this.devToolsSession.Dispose();
478489
this.devToolsSession = null;
479490
}
491+
492+
if (this.SessionId is not null)
493+
{
494+
this.Execute(DriverCommand.Quit, null);
495+
496+
this.SessionId = null;
497+
}
498+
499+
500+
if (this.disposeDriverService)
501+
{
502+
this.driverService.Dispose();
503+
}
480504
}
481505

482506
base.Dispose(disposing);

dotnet/src/webdriver/WebDriver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public bool IsActionExecutor
192192
/// <summary>
193193
/// Gets the <see cref="SessionId"/> for the current session of this driver.
194194
/// </summary>
195-
public SessionId SessionId { get; private set; }
195+
public SessionId SessionId { get; protected set; }
196196

197197
/// <summary>
198198
/// Gets or sets the <see cref="IFileDetector"/> responsible for detecting
@@ -709,6 +709,7 @@ protected bool RegisterInternalDriverCommand(string commandName, CommandInfo com
709709
/// <param name="disposing">if its in the process of disposing</param>
710710
protected virtual void Dispose(bool disposing)
711711
{
712+
// DO NOT SEND QUIT COMMAND IN BASE, CHILDS SHOULD IMPLEMENT IT. REMOVE IN FINAL MERGE.
712713
try
713714
{
714715
if (this.SessionId is not null)

0 commit comments

Comments
 (0)