public function VarbaseContext::iWaitMaxOfSecondsForThePageToBeReadyAndLoaded in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 9.0.x
Same name and namespace in other branches
- 8.8 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iWaitMaxOfSecondsForThePageToBeReadyAndLoaded()
- 8.4 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iWaitMaxOfSecondsForThePageToBeReadyAndLoaded()
- 8.5 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iWaitMaxOfSecondsForThePageToBeReadyAndLoaded()
- 8.6 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iWaitMaxOfSecondsForThePageToBeReadyAndLoaded()
- 8.7 tests/features/bootstrap/VarbaseContext.php \VarbaseContext::iWaitMaxOfSecondsForThePageToBeReadyAndLoaded()
Wait max of seconds for the page to be ready and loaded.
Varbase Context #varbase.
Example 1: And wait Example 2: And I wait Example 3: And wait for the page Example 4: And I wait for the page Example 5: And wait max of 5 seconds Example 6: And wait max of 5s Example 7: And I wait max of 5s Example 8: And I wait max of "5" seconds Example 9: And I wait max of "5" seconds for the page to be ready and loaded.
@Given /^(?:|I )wait max of "(?P<time>\d+)" second(?:|s)(?:| for the page to be ready and loaded)$/ @Given /^(?:|I )wait max of (?P<time>\d+) second(?:|s)(?:| for the page to be ready and loaded)$/ @Given /^(?:|I )wait max of (?P<time>\d+)s(?:| for the page to be ready and loaded)$/ @Given /^(?:|I )wait(?:| for the page)$/
Throws
\WebDriver\Exception If timeout is reached.
File
- tests/
features/ bootstrap/ VarbaseContext.php, line 223
Class
- VarbaseContext
- Defines application features from the specific context.
Code
public function iWaitMaxOfSecondsForThePageToBeReadyAndLoaded($time = 10000) {
if (!$this
->getSession()
->getDriver() instanceof Selenium2Driver) {
return;
}
$start = microtime(TRUE);
$end = $start + $time / 1000.0;
$conditions = [
// Page is ready.
"document.readyState == 'complete'",
// jQuery is loaded.
"typeof \$ != 'undefined'",
// No ajax request is active.
"!\$.active",
// Page is displayed (no progress bar)
"\$('#page').css('display') == 'block'",
// Page is not loading (no black mask loading page)
"\$('.loading-mask').css('display') == 'none'",
// Jstree has finished loading.
"\$('.jstree-loading').length == 0",
];
$condition = implode(' && ', $conditions);
// Make sure the AJAX calls are fired up before checking the condition.
$this
->getSession()
->wait(100, FALSE);
$this
->getSession()
->wait($time, $condition);
// Check if we reached the timeout unless the condition is false to explicitly wait the specified time.
if ($condition !== FALSE && microtime(TRUE) > $end) {
throw new \Exception(sprintf('Timeout of %d reached when checking on %s', $time, $condition));
}
}