giorgiosironi / phpunit-selenium

Selenium RC integration for PHPUnit
http://www.phpunit.de/
Other
601 stars 270 forks source link

Open headless Chrome #429

Closed techhemant closed 5 years ago

techhemant commented 5 years ago

How can run Chrome in headless mode in PHPUnit_Extensions_Selenium2TestCase as there is no direct way to setting chromeoptions.

pajon commented 5 years ago

Hope this will be helpfully. This is for chrome

        $this->setDesiredCapabilities([
            "goog:chromeOptions" => [
                "args"  => [
                    "--headless",
                    "--disable-gpu",
                ],
                // disable loading images
                "prefs" => [
                    "profile" => [
                        "managed_default_content_settings" => [
                            "images" => 2,
                        ],
                    ],
                ],
            ],
        ]);
LukeTowers commented 5 years ago

@pajon you have no idea how long I've just spent scouring the web and digging deep into selenium, chrome, chromedriver documentation, not to mention the source of PHPUnit and PHPUnit_Selenium, plus playing around with direct CURL requests to the Selenium endpoint to try to get this working.

Your solution worked great, thanks so much!

LukeTowers commented 5 years ago

@czerwonyd See the above for how we can use headless chrome. Think about integrating it into your plugin as a part of the configuration that you'll be looking at.

thewunder commented 5 years ago

Even simpler


$this->setDesiredCapabilities(['chromeOptions'=>['args'=>['headless']]]);