-
-
Save hardevine/8280fabf7f3c9594efb467f5ebdd61b2 to your computer and use it in GitHub Desktop.
Simple Laravel Dusk macro that waits for a page change
This file contains hidden or 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 | |
// Define in some ServiceProvider | |
Browser::macro('waitForReload', function () { | |
$this->script("window.duskPageIsStale = {}"); | |
return $this->waitUntil("return typeof window.duskPageIsStale === 'undefined';"); | |
}); | |
// Usage: | |
->click('button') | |
->waitForReload() | |
->assertSee('Something on new page') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment