<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1130759536934730&amp;ev=PageView&amp;noscript=1">
Markus Suonto

container, docker, selenium

| Mar 3, 2017 3:37:33 PM

Selenium & Docker - Match made in heaven

Everyone loves Selenium. And why not, it’s great. Yet, I recall moments of complete frustration when browser drivers fail and I just can’t quite recall the correct version of Firefox to work with a version of Selenium. Don’t get me wrong, I absolutely love version control and virtual environments. In fact, I like virtualenvwrapper so much that I use it even when I am not working with Python. Just because I can and because I like navigating projects with workon. It sets my gopath, path and env. It’s good - trust me. Even though, I plead guilty of sometimes being satisfied with the working system and forgetting to lock down browser or tool versions.

Honestly, browser and tool version control is a solvable problem. You just launch the grid, attach all your favorite browsers, disable updates and install tools with locked versions. Ok, cool. Once you do it, you can relax a bit. Until you want some updates or until you are told that also older versions of browsers must be tested. Then you’re really facing the legendary problem that I know as version matrix.

At this point, the versions of Selenium, browsers and other related tools like Robot Framework and Selenium2Library are bustling in your mind, gently pushing a solitary tear into your eye. Before we get all too emotional here, though, let me tell you something comforting: the time of version incompatibility is over. Furthermore, running different versions of browsers is a robust and swift operation that can in most cases be launched in minutes or even seconds.

To be more accurate, I could reduce the previous statement to “partially obsolete”. The answer is to pack browsers as Docker containers and launch them together with Selenium hub with a single Docker-compose command. Before you get all too excited, I’d recommend checking out Docker Selenium from Github. However, if you’re running out of patience you can move on to Running Eficode Example Already.

In a nutshell, docker hub has images for different versions of Selenium and compatible browser nodes.

docker hub images selenium

Once you connect the nodes, you can run tests with different browsers.

In my opinion, the coolest way to do it in practice is to pack different versions of infra into Docker-compose files and launch them dynamically when you need them:

Docker-compose files

After launching infra, you can run tests for individual browsers or with all browsers at once:

docker test run browsers

If you want to monitor the test execution, use debug images and connect with vnc. Inside you’ll find the completely functional browsers and you can also use the developer tools.

debug images

Pretty cool, huh? Don’t forget that you can always extend the core infra with virtual machines if you need to test more exotic browsers like Internet Explorer or Safari.

READ MORE

Jeeves, get me more

BLOG POSTS
BLOG FEED
NEWS
EVENTS
CAREER STUFF

Search