Skip to content

Commit

Permalink
MDL-56898 behat: Go to a non html page to avoid any unwanted ajax calls
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Rajesh Taneja committed Nov 21, 2016
1 parent 2db00c9 commit 9136cf7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/tests/behat/behat_hooks.php
Expand Up @@ -368,6 +368,29 @@ function($errno, $errstr, $errfile, $errline) {
$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.
*
Expand Down

0 comments on commit 9136cf7

Please sign in to comment.