Running Robot Framework scripts in a Docker container

Running Robot Framework scripts in a Docker container

At Tacit Knowledge, Quality Assurance (QA) process is integrated into the Software Development Lifecycle. QA is a source of feedback at all the development stages.

We work with at least 3 pre-production environments: Development, QA, UAT/Demo. Then, by running different levels of testing we ensure that everything is working well.

This requires the use of automated checks/tests to verify vital user paths and critical functionality. Most of our automated functional tests are written in Robot Framework. Scripts are automatically started by the CI server after a deployment of new code.

By running these scripts we minimize the risk of introducing regression bugs. They work as a source of information/feedback providing a quick health check.

This works perfectly as part of our continuous integration process. But what if I don’t want to break the build when introducing new code? I don’t want to pay for lunch because I broke the build. Run the scripts in your local environment you must!

There are also scenarios in which we have the classic: it works on my machine or I cannot replicate it. These problems are caused by the different platforms that we use: our continuous integration is running on Linux, we use Macs for our development environment, and sometimes we work with teams that use Windows machines.

In the past, we manually installed all the prerequisites to run our Robot test suite. This ended up being a tedious process as nobody ever installed the toolkit: ain’t nobody got time for that. Then, we tried using build tools like Maven and Paver: they worked for a while, but they required additional work such as creating/maintaining things like POM files and compiling some libraries using Jython.

Then, we found Docker! After a quick read of the documentation and the completion of the tutorial, we decided to integrate our Robot Framework scripts into Docker. The reasons behind this are very simple:

  • Ease the setup process of the whole toolkit.
  • Provide a simplified way to share and run our automated test scripts.
  • Standardized testing environment. The same VM is running on different platforms.

We started creating our first Dockerfile:

FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y python-pip python-dev gcc phantomjs firefox
RUN pip install robotframework
RUN pip install robotframework-sshlibrary
RUN pip install robotframework-selenium2library

When we ran this image in a Docker container, we discovered that we needed a display in order to run our scripts in Firefox. So we installed Xvfb. It was required to initialize and demonize a Xvfb virtual display so we had to create a couple of bash scripts and we added them to our Dockerfile:

ADD xvfb_init /etc/init.d/xvfd
RUN chmod a+x /etc/init.d/xvfb
ADD xvfb-daemon-run /usr/bin/xvfb-daemon-run
RUN chmod a+x /usr/bin/xvfb-daemon-run

Next, we decided to automatically checkout the code, thus we added one more line:

RUN git clone ssh://@/

We finally had a proper setup for running Robot test scripts. It was time to invoke our automated test suite! So we created another bash script ( that contained a pybot invocation. Then we added it to our Dockerfile:

ADD /storefront-qa/robot/
RUN chmod a+x /storefront-qa/robot/

It’s done!, everything is in place!. If you want to test this solution just run the following command in a terminal:

docker run -ti bash -c “./”

Hope you enjoy!

About Tacit Knowledge
Tacit Knowledge is a digital commerce consultancy focused on creating value for our clients by helping them consistently satisfy and delight shoppers across all channels and devices.
SAP Hybris 6.3

SAP Hybris 6.3

Following the release of the SAP Hybris 6.3, the latest version of the leading commerce platform, we’ve had time to evaluate some of the key benefits for both B2C and B2B companies. Here’s what we think!
Read More
What Retailers Need to Consider Before Developing a Mobile App.

What Retailers Need to Consider Before Developing a Mobile App.

These days, it comes as no surprise when your mom – or grandma – shoots you a text message laden with...
Read More
1 2 3 6