New Headless Chrome in Geb New Headless Chrome in Geb selenium selenium

New Headless Chrome in Geb


Okay, so I managed to get this working in Geb's sample Gradle project with the following GebConfig.groovy, BUT, I had to update the version of ChromeDriver in the build.gradle file from 2.24 to 2.29 for it to play nicely with the newest version of Chrome.

import org.openqa.selenium.chrome.ChromeDriverimport org.openqa.selenium.chrome.ChromeOptionsimport org.openqa.selenium.remote.DesiredCapabilitieswaiting {        timeout = 2    }    environments {        // run via “./gradlew chromeTest”        // See: http://code.google.com/p/selenium/wiki/ChromeDriver        chrome {            driver = {                ChromeOptions options = new ChromeOptions()                DesiredCapabilities capabilities = DesiredCapabilities.chrome()                String chromiumPath = "/usr/bin/chromium-browser"                String macChromePath = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"                def chromiumBinary = new File(chromiumPath)                def isAgent = chromiumBinary.exists()                def macChromeBinary = new File(macChromePath)                if (isAgent) {                    options.setBinary(chromiumBinary) //Set binary using file to avoid NoClassDefFound error on mac                } else if (macChromeBinary.exists()) {                    options.setBinary(macChromeBinary)                }                options.addArguments("headless")                capabilities.setCapability(ChromeOptions.CAPABILITY, options)                new ChromeDriver(capabilities)            }        }    }

It seems like adding the remote-debugging-port option is what causes the slowdown/breakage. disable-gpu seems fine, though.

options.addArguments("headless", "disable-gpu")