Created
March 8, 2024 16:28
-
-
Save jerclarke/c5328ed59571a88342034e15c90a3c33 to your computer and use it in GitHub Desktop.
Codeception confirm page reloaded helpers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Helper methods to add to the acceptance tester class ($I) | |
/** | |
* Run this before submitting a form/clicking link when we want to check the page reloaded later | |
* | |
* Sets a JS var that we can check later to know that the page | |
* has reloaded | |
* | |
* @param AcceptanceTester $I | |
* @return void | |
*/ | |
public function gvAmOnPageBeforeReload(\AcceptanceTester $I) { | |
$I->waitForJS('return document.oldPage = "yes"'); | |
} | |
/** | |
* Run this after submitting form/clicking link to confirm page has reloaded | |
* | |
* @param AcceptanceTester $I | |
* @return void | |
*/ | |
public function gvAmOnPageAfterReload(\AcceptanceTester $I) { | |
$I->waitForJS('return document.oldPage !== "yes"'); | |
} | |
# Example usage in a test helper method: | |
public function _gvUserProfileUpdateEmail(AcceptanceTester $I, string $email) { | |
$I->fillField(['name' => 'email'], $email); | |
$I->scrollTo("#wpfooter"); | |
$I->gvAmOnPageBeforeReload($I); | |
$I->click('Update User'); | |
$I->gvAmOnPageAfterReload($I); | |
$I->seeInField('email', $email); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment