Summer Sale! All accounts are 50% off this week.

realtebo's avatar

Dusk : how to disable extensions?

I want to preserve console logs, but not this

DevTools listening on ws://127.0.0.1:60060/devtools/browser/63524023-c3d1-4db5-a823-b4d8f52a5bfd

So I am tried to add an option to disable extensions in tests/DuskTestCase.php

    protected function driver()
    {
        $options = (new ChromeOptions)->addArguments([
            '--disable-gpu',
            '--headless',
            '--window-size=1920,1080',
            '--ignore-certificate-errors',
            '--ignore-ssl-errors',
            '--disable-extensions',
        ]);

        return RemoteWebDriver::create(
            $_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515',
            DesiredCapabilities::chrome()->setCapability(
                ChromeOptions::CAPABILITY, $options
            )
        );
    }

Note --disable-extensions

When I run php artisan dusk, anyway, it shos me the console.log about DevTools.

0 likes
3 replies
Braunson's avatar

To hide console errors add this to the arguments but it depends on the Chrome version you are running.

'--log-level=3',
'--silent'
realtebo's avatar

@Braunson it works but it cannot silence normal logs and warnings.

0517/160639.981:INFO:CONSOLE(50)] "JQMIGRATE: jQuery.fn.load() is deprecated", source: https://demetra-test.test/js/vendors.js (50)
[0517/160639.981:INFO:CONSOLE(52)] "console.trace", source: https://demetra-test.test/js/vendors.js (52)
Braunson's avatar

@realtebo If my previous snippet doesn't work, depending on what version your running try adding this (as it changed with v75+)

$options->setExperimentalOption('excludeSwitches', [enable-logging']);

If that doesn't work, I'd look at what headless Chrome version your are using then hit the Chrome docs to see what flag there is.

Please or to participate in this conversation.