Skip to content

Commit 6a2d3c0

Browse files
committed
Chain of disposal
1 parent 07861c5 commit 6a2d3c0

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

dotnet/src/webdriver/Firefox/FirefoxDriver.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,12 +491,25 @@ protected override void Dispose(bool disposing)
491491

492492
if (this.SessionId is not null)
493493
{
494-
this.Execute(DriverCommand.Quit, null);
495-
496-
this.SessionId = null;
494+
try
495+
{
496+
this.Execute(DriverCommand.Quit, null);
497+
}
498+
catch (NotImplementedException)
499+
{
500+
}
501+
catch (InvalidOperationException)
502+
{
503+
}
504+
catch (WebDriverException)
505+
{
506+
}
507+
finally
508+
{
509+
this.SessionId = null;
510+
}
497511
}
498512

499-
500513
if (this.disposeDriverService)
501514
{
502515
this.driverService.Dispose();

dotnet/test/common/TempSharedDriverServiceTest.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ public void ChromeImplicitly()
1414
{
1515
using (var driver = new ChromeDriver())
1616
{
17-
17+
driver.Close();
18+
driver.Quit();
19+
driver.Dispose();
1820
}
1921

2022
Assert.That(Process.GetProcessesByName("chromedriver"), Is.Empty);
@@ -55,7 +57,9 @@ public void FirefoxImplicitly()
5557
{
5658
using (var driver = new FirefoxDriver())
5759
{
58-
60+
driver.Close();
61+
driver.Quit();
62+
driver.Dispose();
5963
}
6064

6165
Assert.That(Process.GetProcessesByName("geckodriver"), Is.Empty);

0 commit comments

Comments
 (0)