Set up and run your Cucumber and Selenium web tests on Gitlab-CI within minutes

(CI-CD) continuous integration and continuous deployment pipeline

Build great software faster! CI/CD is hot and is still gaining interest. Test Automation is obviously essential within any Continuous Integration setup in order to get test feedback often and fast. 

Within the test automation groups here at spriteCloud we have seen a lot of different setups. We have been integrating test automation into CI tools such as Jenkins, TeamCity, Travis, TFS, Circle CI, Bamboo and Gitlab. Out of all the solutions we are a big fan of Gitlab, especially since it is making the integration of test automation a breeze.

For more information about Test Automation and Cucumber, read our guides, ‘Test Automation: nearly everything you need to know’ and ‘Cucumber and Gherkin: a guide to open-source automation testing.’

We are also a big fan of our own test results dashboard Calliope Pro which allows testers to monitor, share, and compare test results with the rest of the development team. The benefit, aside from the collaborative aspects of Calliope, is being able to see the status of test results over time which is crucial to maintain a healthy CI/CD process. Give Calliope Pro a try for free today.

.gitlab.yml config file for your Selenium tests

So without further ado, let’s give you the complete code you need to run your tests within a Gitlab CI:

image: ruby:2.3

- selenium/standalone-chrome:latest
  selenium_remote_url: "http://selenium__standalone-chrome:4444/wd/hub/"
  - cucumber -t @mytag

Wait, what? I only need a configuration file? That’s it? Yes!

There are some prerequisites of course:

  • Have the Gitlab runner executor set to ‘docker’ (for this example)
  • use your selenium_remote_url environment variable within your test scripts. The selenium chrome service we started is accessible through: http://selenium__standalone-chrome:4444/wd/hub/

Let’s make the CI setup a bit more efficient though by adding some caching:

image: ruby:2.3

- selenium/standalone-chrome:latest

  selenium_remote_url: "http://selenium__standalone-chrome:4444/wd/hub/"

  - "./cache/ruby"

- bundle install --path ./cache

  - bundle exec cucumber -t @mytag


Configure your Selenium remote URL

The last thing to keep in mind is to include the selenium_remote_url in the test scripts. Here at spriteCloud we are using our open-source gem lapis-lazuli in order to quickly setup Ruby, Cucumber and Selenium test automation suites. This is how you integrate the URL within such a test suite:

require 'lapis_lazuli'
require 'lapis_lazuli/cucumber'


LapisLazuli.Start do
  browser :remote, {
    :url => ENV['selenium_remote_url'],
    :caps => {
      "browser" => "Chrome"

But of course you can use selenium-webdriver directly as well if you want:

require 'selenium-webdriver'
driver = Selenium::WebDriver.for :remote,
                                 :url => ENV['selenium_remote_url'],
                                 :desired_capabilities => :chrome

Want to try this out yourself in Gitlab? We have setup an example Gitlab project where you can see it in action! Gitlab Cucumber Selenium CI test setup. Enjoy!

If you want to get started with test automation using ruby and cucumber you can read our introduction post about Lapis Lazuli and be sure to also read “Getting started with test automation: Cucumber with Lapis Lazuli”.

Written by: Mark Barzilay

Graduated with honors from TU Delft in 2007 studying Electrical Engineering and Media & Knowledge Engineering. Founded spriteCloud in 2009 and worked on test automation ever since, helping out small and large companies with their test automation strategy and infrastructure. Mark is also leading the development on, an online platform for all your automated test results.

Subscribe to our mailing list!

Stay up-to-date on all things quality assurance,
test automation, and cybersecurity.

We’re spriteCloud, a leader in software and cybersecurity testing.


Have a look at our testing solutions.