Skip to content

Commit

Permalink
MDL-66979 behat: Handle driver stop failure properly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andrewnicols committed Jan 28, 2021
1 parent 0bac7fa commit 7cff15d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/tests/behat/behat_hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,24 @@ public function after_step_javascript(AfterStepScope $scope) {
* @AfterScenario
*/
public function reset_webdriver_between_scenarios(AfterScenarioScope $scope) {
$this->getSession()->stop();
try {
$this->getSession()->stop();
} catch (Exception $e) {
$error = <<<EOF
Error while stopping WebDriver: %s (%d) '%s'
Attempting to continue with test run. Stacktrace follows:
%s
EOF;
error_log(sprintf(
$error,
get_class($e),
$e->getCode(),
$e->getMessage(),
format_backtrace($e->getTrace(), true)
));
}
}

/**
Expand Down

0 comments on commit 7cff15d

Please sign in to comment.