Docker Compose Cucumber for Cross-Browser Testing

Docker-Compose

Docker is the trending tool in the recent days which allows us to run multiple lightweight containers to perform various task. Just in case, you haven’t got docker please refer my previous post ‘Guide to Docker ToolBox‘ to start Docker from scratch.

Docker-compose is a way of managing multiple containers to perform specific tasks. It allows us to create ‘docker-compose.yml’ file with our container requirements. You can install docker-compose in with PIP with single command.

In this short post, we will setup Ruby-Cucumber to run scenarios in the multiple browses. We will execute it in PhantomJS based Poltergeist driver.

Docker-Compose Cucumber

We will consider two basic scenarios here.

  • You have existing cucumber framework setup
  • You have to start from scratch

Existing Cucumber Framework

Assuming, you have created Dockerfile & profile for those browsers and registered drivers. This also assumes that you have docker image provisioned with specific webdriver drivers e.g firefox-driver, chrome-driver etc

You can create a docker-compose.yml fie which looks like this :

This will allow us to setup multiple browsers in our cucumber.

 Start from Scratch

I have created little project on Github to start with Docker-Compose with Cucumber.

https://github.com/Shashikant86/docker-compose-cucumber

You can clone this repo and use it directly.

You have all the setup ready.

Configuring Docker-Compose File

Now have a look at ‘docker-compose.yml’ file. It has phantomjs and chrome profile. You can update file according to the browser and cloud testing services you use like Saucelabs, Testingbot and Browserstack.

  • Using With PhantomJS

You can use headless browser PhantomJS with Poltergeist driver.

 

  • Using with Chrome

You have to make sure, Docker image has chrome and chrome-driver installed.

You can also use other drivers as well if you have Saucelabs, Browserstack Key setup in the ‘features/support/env.rb’ file.

Now run Docker Compose

This will build and run cucumber scenarios in the different containers with different browsers.

docker-compose-cucumber-

You can see above two containers has been launched, one for phantomJS and other for chrome.

Video Demo

  • Installing Docker Toolbox

  • Docker-Compose Cucumber Cross Browser