/**
* @param int $timeout : timeout period
* @throws ModuleException
*/
public function waitAjaxLoad($timeout = 10)
{
$this->webDriverModule->waitForJS('return !!window.jQuery && window.jQuery.active == 0;', $timeout);
$this->webDriverModule->wait(1);
$this->dontSeeJsError();
}
/**
* @param int $timeout : timeout period
* @throws ModuleException
*/
public function waitPageLoad($timeout = 10)
{
$this->webDriverModule->waitForJs('return document.readyState == "complete"', $timeout);
$this->waitAjaxLoad($timeout);
$this->dontSeeJsError();
}
These two functions did not work for me. Are there any workaround to wait until the redirected page is loaded?
Most stable solution I found:
$I->waitForJS('return document.oldPage = "yes"');
$I->submitForm('form', ['field1' => 'xyz']);
$I->waitForJS('return document.oldPage !== "yes"');
Because it when i trigger submitForm it doesn't wait for the page to load, and the page is still active for a short period until it starts to load, and once it starts to load the JS stops to evaluate and start once it's loaded.