Stories, software, and a life lived across several worlds
To run acceptance tests for a web application you want to use a real web browser just the same way a regular human user would do. With tools like Cucumber it is common to use Selenium WebDriver to remotely control a web browser like Chrome, Firefox, Internet Explorer or Safari.
My web application is being delivered as an executable JAR file created with Spring Boot that is packaged up as a Docker container. As in the previous example I use a Jenkins pipeline to build my project and put the resulting artifact into a Docker container that then gets put through the pipeline until it reaches a production environment. Before I was running my Cucumber acceptance tests in a separate container that is able to use the container under test.
I’ve been toying with the idea to install Chrome and the Chromedriver onto the same Ruby/Cucumber container. That seems what people have been doing before and it seems ok. But it never really worked for me. Plus, it seems that this is an approach one would use with a virtual machines while containers are not virtual machines per se. The idea behind Docker containers is part of a different philosophy which is basically: one application per container.
Thankfully the Selenium project is providing ready to use Docker containers for the exact same purpose I’m after. So here is my docker-compose.yml and you can see I’m using a third container in my setup: selenium/standalone-chrome
Note the line JAVA_OPTS=-Dselenium.LOGGER.level=WARNING. Without it the Selenium container will drown your console or logfile in INFO level messages for every request that comes in.
version: '3'
services:
meal-planner-app:
image: snscaimito/meal-planner-app:latest
ports:
- "9080:8080"
selenium:
image: selenium/standalone-chrome
environment:
- JAVA_OPTS=-Dselenium.LOGGER.level=WARNING
ports:
- "4444:4444"
links:
- meal-planner-app
cucumber:
environment:
- HOST=meal-planner-app
- PORT=8080
links:
- meal-planner-app
- selenium
volumes:
- ./:/home/cucumber
build:
context: ./
dockerfile: Dockerfile-cucumber
When I run docker-compose it will start up all three containers in the right order and make them visible to each other (note the links statements). Then I can create my Watir::Browser like this:
browser = Watir::Browser.new :chrome, {timeout: 120, url: "http://selenium:4444/wd/hub"}
From that point on my Cucumber scenarios run as usual. I get screenshots taken when a scenario fails. In Jenkins I’m using the Cucumber Reports plugin.

| Previous | 07 Jan 2018 | Next |
About me
Hello! My name is Stephan Schwab.
I build and rescue software, and I write fiction about the human side of how it gets made. Here you’ll find my stories and novelas, notes on craft, and field notes from a life lived across several worlds.
Working with software teams is what I do professionally — see how on caimito.net. You can also read about my experience since 1986.
Work with me
Hire me as the senior who embeds in your team and makes it ship.
Stories & writing
On the craft
Life across several worlds
Places that shaped me
Open Source
Stay in touch
LinkedIn Mastodon Bluesky TikTok Twitter RSS Email
Everything
See a listing of all posts on this site.