Let's talk about testing

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

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.

.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!

Further reading:
– If you want to get started with test automation using ruby and cucumber you can read Getting started with test automation: Cucumber with Lapis Lazuli.

Comments are closed.

Reputation. Meet spriteCloud

Find out today why startups, SMBs, enterprises, brands, digital agencies, e-commerce, and mobile clients turn to spriteCloud to help improve their customer experiences. And their reputation. With complete range of QA services, we provide a full service that includes test planning, functional testing, test automation, performance testing, consultancy, mobile testing, and security testing. We even have a test lab — open to all our clients to use — with a full range of devices and platforms.

Discover how our process can boost your reputation.

We use cookies to give you the best browsing experience possible. For more information, please read our cookie policy.

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.