Testing with headless chrome
The new headless feature in Chrome 59, makes it easy to run gauge with selenium on a CI/CD setup or Docker instances without having to use xfvb
.
Java
For Maven add the following dependencies to pom.xml
.
For Gradle add dependencies to build.gradle
webdrivermanager
is a library that automatically downloads and manages chromedriver
.
Initialize WebDriver
with arguments for headless mode and run tests.
Ruby
If you are using bundler add this to your Gemfile
And initialize a driver
Gauge
Gauge sets all of this via project templates!
For a maven selenium project run
$ gauge init java_maven_selenium
$ cd <projectdirectory>
$ headless=Y gauge run specs
Or for setting up a ruby project
$ gauge init ruby_selenium
$ headless=Y bundle exec gauge run specs
Screenshot on failure
By default, Gauge captures the screen display. In headless mode, the browser is not launched into a display, use getScreenShotAs
method in WebDriver
to capture the browser’s screenshot instead.
For Gauge, implement a custom screenshot handler.
Have fun setting up tests in headless mode!