Skip to content

Instantly share code, notes, and snippets.

Created April 27, 2017 16:45
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Simple Laravel Dusk macro that waits for a page change
// Define in some ServiceProvider
Browser::macro('waitForReload', function () {
$this->script("window.duskPageIsStale = {}");
return $this->waitUntil("return typeof window.duskPageIsStale === 'undefined';");
// Usage:
->assertSee('Something on new page')
Copy link

little improve, execute a script or click inside the callback which expects to reload page:

    public function waitForNavigation($callable)
        $this->driver->executeScript('window.oldPageStillIn = {}');

        return $this->waitUntil("return typeof window.oldPageStillIn === 'undefined';");

Copy link


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment