From 675e9810047f0fa0b0c4f8f6136d02562975074c Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Mon, 15 Jun 2020 10:37:52 +0800 Subject: [PATCH] MDL-69072 behat: Relaunch browser session between scenarios --- lib/tests/behat/behat_hooks.php | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 115765a97f0..5ee4caf1b14 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -576,25 +576,13 @@ class behat_hooks extends behat_base { } /** - * Executed after scenario having switch window to restart session. - * This is needed to close all extra browser windows and starting - * one browser window. + * Reset the session between each scenario. * * @param AfterScenarioScope $scope scope passed by event fired after scenario. - * @AfterScenario @_switch_window + * @AfterScenario */ - public function after_scenario_switchwindow(AfterScenarioScope $scope) { - for ($count = 0; $count < behat_base::get_extended_timeout(); $count++) { - try { - $this->getSession()->restart(); - break; - } catch (DriverException $e) { - // Wait for timeout and try again. - sleep(self::get_timeout()); - } - } - // If session is not restarted above then it will try to start session before next scenario - // and if that fails then exception will be thrown. + public function reset_webdriver_between_scenarios(AfterScenarioScope $scope) { + $this->getSession()->stop(); } /** -- 2.43.0