Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@calebporzio
Created April 27, 2017 16:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save calebporzio/eb5cae2064a96e4fbf8f2ecf01626305 to your computer and use it in GitHub Desktop.
Save calebporzio/eb5cae2064a96e4fbf8f2ecf01626305 to your computer and use it in GitHub Desktop.
Simple Laravel Dusk macro that waits for a page change
<?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')
@calebporzio
Copy link
Author

Nice!

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