Skip to content

Commit

Permalink
Merge pull request #5 from jonag/ajax_exception
Browse files Browse the repository at this point in the history
Throw an exception if there is still a ajax call after the timeout
  • Loading branch information
thomasbeaujean authored Feb 27, 2017
2 parents 826010b + e8c93e6 commit fd879f2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Traits/MinkTrait.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Behat\Mink\Exception\ElementNotFoundException;
use A5sys\MinkContext\Exception\ElementNotVisibleException;
use Behat\Mink\Exception\ExpectationException;

/**
*
Expand Down Expand Up @@ -145,10 +146,16 @@ public function scrollToTop()
* I wait for all ajax done
*
* @When /^(?:|I )wait for ajax to be done$/
* @throws \Behat\Mink\Exception\ExpectationException
*/
public function iWaitForAjaxDone()
{
$this->getSession()->wait($this->ajaxTimeout, '(0 === jQuery.active)');
if ($this->getSession()->wait($this->ajaxTimeout, '(0 === jQuery.active)') === false) {
throw new ExpectationException(
sprintf('There is still an ajax call active after %d milliseconds.', $this->ajaxTimeout),
$this->getSession()
);
};
}

/**
Expand Down

0 comments on commit fd879f2

Please sign in to comment.