*/
const PAGE_LOAD_DETECTION_STRING = 'new_page_not_loaded_since_behat_started_watching';
+ /**
+ * @var $pageloaddetectionrunning boolean Used to ensure that page load detection was started before a page reload
+ * was checked for.
+ */
+ private $pageloaddetectionrunning = null;
+
/**
* Opens Moodle homepage.
*
throw new ExpectationException('Page load expectation error: page reloads are already been watched for.');
}
+ $this->pageloaddetectionrunning = true;
+
$this->getSession()->evaluateScript(
'var span = document.createElement("span");
span.setAttribute("data-rel", "' . self::PAGE_LOAD_DETECTION_STRING . '");
$this->getSession()
);
}
+
+ if (!$this->pageloaddetectionrunning) {
+ throw new ExpectationException(
+ 'Page load expectation error: page load tracking was not started.',
+ $this->getSession());
+ }
+
+ // Cancel the trakcing of pageloaddetectionrunning.
+ $this->pageloaddetectionrunning = false;
}
/**