From ebd36d2ac271fd71bf28a3935facf5403242dd15 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 28 Jan 2021 14:51:29 +0800 Subject: [PATCH] MDL-66979 behat: Handle driver stop failure properly An case was found where the webdriver stop() call could fail in an AfterScenario hook, leading to a complete rerun if no other errors were experienced. --- lib/tests/behat/behat_hooks.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index d7fc9e77287..06f78785923 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -660,7 +660,24 @@ EOF; * @AfterScenario */ public function reset_webdriver_between_scenarios(AfterScenarioScope $scope) { - $this->getSession()->stop(); + try { + $this->getSession()->stop(); + } catch (Exception $e) { + $error = <<getCode(), + $e->getMessage(), + format_backtrace($e->getTrace(), true) + )); + } } /**