diff --git a/src/Dusk/Browser.php b/src/Dusk/Browser.php index 549cd70..7e0dcc6 100644 --- a/src/Dusk/Browser.php +++ b/src/Dusk/Browser.php @@ -2,6 +2,7 @@ namespace BeyondCode\DuskDashboard\Dusk; +use Closure; use BeyondCode\DuskDashboard\BrowserActionCollector; class Browser extends \Laravel\Dusk\Browser @@ -61,6 +62,28 @@ public function refresh() return $browser; } + /** {@inheritdoc} */ + public function with($selector, Closure $callback) + { + $action_collector_callback = function ($browser) use ($callback) { + $browser->setActionCollector($this->getActionCollector()); + + return $callback($browser); + }; + + return parent::with($selector, $action_collector_callback); + } + + /** {@inheritdoc} */ + public function onComponent($component, $parentResolver) + { + if ($this->getActionCollector() === null) { + $this->setActionCollector(new BrowserActionCollector('dog')); + } + + parent::onComponent($component, $parentResolver); + } + public function getCurrentPageSource() { $this->ensurejQueryIsAvailable();