From b3c68c5a9d86860c28b9d34d3ad0c0f124548782 Mon Sep 17 00:00:00 2001 From: Andrew Lyons Date: Fri, 30 Aug 2024 04:31:08 +0800 Subject: [PATCH] Reset driver connection even if stopping the driver fails (#87) --- src/WebDriver.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/WebDriver.php b/src/WebDriver.php index 641b4f8..ab26009 100755 --- a/src/WebDriver.php +++ b/src/WebDriver.php @@ -289,9 +289,11 @@ public function stop() try { $this->webDriver->quit(); - $this->webDriver = null; } catch (\Exception $e) { throw new DriverException('Could not close connection', 0, $e); + } finally { + // Note: The finally section will be executed before the DriverException is thrown. + $this->webDriver = null; } }