Dusk: Dusk screenshots from Chrome are cropped, so I can only see the right-hand side of the screen

Created on 21 May 2017  路  2Comments  路  Source: laravel/dusk

I'm running Dusk tests via Chrome on a 27" iMac, which automatically opens Chrome filling the entire left-hand side of the screen. Errors appear normally within Chrome, but the screenshots of those errors are badly cropped when saved by Dusk - with about half of the left side of the screenshot chopped off.

I'm aware that WebDriver has a Chrome flag available, --start-maximized, but I can't figure out where to put it within Dusk to have any effect.

Is this a known bug with Dusk, or if not, where would I go adding the --start-maximized option to have any effect?

Most helpful comment

Try this in your DuskTestCase.php:

    protected function driver()
    {
        $options = new ChromeOptions();

        // for windows you should use --start-maximized key here
        $options->addArguments(['--kiosk']);

        $capabilities = DesiredCapabilities::chrome();
        $capabilities->setCapability(ChromeOptions::CAPABILITY, $options);

        return RemoteWebDriver::create(
            'http://localhost:9515',
            $capabilities
        );
    }

All 2 comments

Try this in your DuskTestCase.php:

    protected function driver()
    {
        $options = new ChromeOptions();

        // for windows you should use --start-maximized key here
        $options->addArguments(['--kiosk']);

        $capabilities = DesiredCapabilities::chrome();
        $capabilities->setCapability(ChromeOptions::CAPABILITY, $options);

        return RemoteWebDriver::create(
            'http://localhost:9515',
            $capabilities
        );
    }

@novitskiy-aleksei Nice one - that does the trick. Thanks for your help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

digitlimit picture digitlimit  路  4Comments

marcusmoore picture marcusmoore  路  3Comments

dmitryuk picture dmitryuk  路  5Comments

susanBuck picture susanBuck  路  6Comments

godruoyi picture godruoyi  路  6Comments