Search code examples
laravellaravel-dusk

Laravel Dusk: how to add PageLoadStrategy='none'?


I need my dusk test suite to wait until every single page is full loaded.

We received suggestion to "add PageLoadStrategy='none'"

... but where and how to add this in the context of Laravel 9 + Dusk ?


Solution

  • Found:

    tests/DuskTestCase.php
    

    In protected function driver(), I modified $options for my specific use case

        $options = (new ChromeOptions)->addArguments(collect([
            $this->shouldStartMaximized() ? '--start-maximized' : '--window-size=1920,1080',
            '--disable-web-security',
            '--page-load-strategy=none'
        ])->unless($this->hasHeadlessDisabled(), function ($items) {
            return $items->merge([
                '--disable-gpu',
                '--disable-web-security',
                '--user-data-dir=C:/Chromedevsession',
                '--page-load-strategy=none',
                '--headless',
                '--aggressive-cache-discard',
                '--log-level=3', 
                '--silent'       
            ]);
        })->all());