MDL-56898 behat: Go to a non html page to avoid any unwanted ajax calls

After scenario is finished, go to README.txt, so
there is no JS/AJAX calls pending and site is ready
for reset before next scenario
This commit is contained in:
Rajesh Taneja 2016-11-18 07:34:31 +08:00
parent d9a9a87835
commit 26fef01b6b
No known key found for this signature in database
GPG Key ID: B363F7FB787F80E4

View File

@ -411,6 +411,29 @@ class behat_hooks extends behat_base {
$this->resize_window('medium');
}
/**
* Executed after scenario to go to a page where no JS is executed.
* This will ensure there are no unwanted ajax calls from browser and
* site can be reset safely.
*
* @param AfterScenarioScope $scope scope passed by event fired after scenario.
* @AfterScenario
*/
public function after_scenario(AfterScenarioScope $scope) {
try {
$this->wait_for_pending_js();
$this->getSession()->visit($this->locate_path('/README.txt'));
$this->getSession()->reset();
} catch (DriverException $e) {
// Try restart session, if DriverException caught.
try {
$this->getSession()->restart();
} catch (DriverException $e) {
// Do nothing, as this will be caught while starting session in before_scenario.
}
}
}
/**
* Wait for JS to complete before beginning interacting with the DOM.
*