You are here

public function TestSubContext::afterStepWaitForJavascript in Panopoly 8.2

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

After every step, we want to wait for AJAX loading to finish.

Only for @javascript scenarios.

@AfterStep

File

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

Class

TestSubContext
Behat sub-context for Panopoly.

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)) {
      $this
        ->iWaitForAjax();

      // For whatever reason, the above isn't very accurate inside iframes.
      if (!empty($this->iframe)) {
        sleep(3);
      }
    }
  }
}