You are here

public function TestSubContext::afterStepWaitForJavascript in Panopoly 7

Same name and namespace in other branches
  1. 8.2 modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc \TestSubContext::afterStepWaitForJavascript()

After every step in a @javascript scenario, we want to wait for AJAX loading to finish.

@AfterStep

File

modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc, line 296
Provide Behat step-definitions for generic Panopoly tests.

Class

TestSubContext

Code

public function afterStepWaitForJavascript($event) {
  if (isset($this->javascript) && $this->javascript) {
    $text = $event
      ->getStep()
      ->getText();
    if (preg_match('/(follow|press|click|submit|viewing|visit|reload|attach)/i', $text)) {
      if (empty($this->iframe)) {
        $this
          ->iWaitForAjax();
      }
      else {

        // For whatever reason, the above isn't very accurate inside iframes,
        // and can sometimes cause "Cannot find context with specified id" error.
        sleep(3);
      }
    }
  }
}