From 61358a918ddd068933c23407e0a3ff63054bbb7d Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 29 Jan 2016 11:35:45 +0800 Subject: [PATCH] MDL-52932 behat: Restart session if it fails because of some reason --- lib/tests/behat/behat_hooks.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 78ea80959a9..cd1fd845738 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -393,7 +393,17 @@ class behat_hooks extends behat_base { * @AfterScenario @_switch_window */ public function after_scenario_switchwindow(ScenarioEvent $event) { - $this->getSession()->restart(); + for ($count = 0; $count < self::EXTENDED_TIMEOUT; $count) { + try { + $this->getSession()->restart(); + break; + } catch (DriverException $e) { + // Wait for timeout and try again. + sleep(self::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. } /**