Created
April 27, 2017 16:45
-
-
Save calebporzio/eb5cae2064a96e4fbf8f2ecf01626305 to your computer and use it in GitHub Desktop.
Simple Laravel Dusk macro that waits for a page change
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 | |
// 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
little improve, execute a script or click inside the callback which expects to reload page: