Setting up a Selenium Grid with Docker containers for multi-browser coverage

Selenium is a popular tool for end-to-end testing of web-apps. It’s grid capability allows to have fast test executions, across multiple browsers, in parallel. However, the setup of such environment is always an issue to deal with. That is why, for our setup of Selenium Grid, we decided to use Docker containers to standardize the creation of the Hub and Nodes. This allowed us to have nodes that can be easily re-built, are source-controlled, re-usable and isolated from each other. Additionally, we had special issues come up when working with Safari and IE.

This article is intended as a general reference to follow along to, in order to easily set up a new Selenium grid with Docker, condensing everything we learned during the process. We also give some insight on SE-Interpreter, (the tool we decided to use to communicate with the Selenium Grid) – as to why we chose it and what benefits it has.

Selenium-grid Organization Diagram

Our Selenium Grid currently supports all 4 major browsers through Docker containers and VMs.  Our Chrome and Firefox instances are the most used, so the containers for them are ready to be instantiated at any moment. Having 8 of them ensures a quick execution, given that deployments do not happen too often (unlike regular builds on commits/push).

For the Safari and IE nodes, these are run a bit less frequently then Chrome and Firefox, only for compatibility validation, so 1 VM for each one suffices.


Selenium nodes as Docker containers:  Adding nodes on-demand

It becomes too time-consuming to set up and maintain VM’s for each selenium instance assigned to a specific browser, so instead, we decided to have them using Docker containers. These can be maintained through source-controlled code, and can be instantiated as needed. It also helps solve yet another one of the many problems of UI tests, that they are often slow to run. Adding temporary Docker containers helps reduce execution time and can be destroyed when not in full use. The containers can also be used locally during the development of new tests, that way the Selenium Grid is always free to run product deployments.

The Grid setup consists in a Docker Compose file, which creates the Central Grid Hub and the Chrome+Firefox nodes. We use the official Chrome and Firefox debug-node containers given by the Selenium project. Unlike the regular nodes, the debug nodes allow remote access to them through VNC, which is useful for tracking the tests during development and execution. Adding Chrome or Firefox nodes is a simple matter of cloning, it’s container definition in the Docker compose file by adding a number in its name (firefox2 or chrome3).

Related Content
Man working on laptop, free public domain CC0 photo
Enhancing Accessibility in Jira & Confluence with Unstoppable
Discover how Unstoppable enhances accessibility in Jira and Confluence, making these tools more inclusive...
addteq_fb_product4-1
Editable Excel Sheet in Confluence: Best Tools & Methods
Learn how to import and edit an Excel sheet in Confluence. Discover the best tools, including Excellentable,...
Excellentable collaborative editing
Unlock the power of Pivot Tables in Confluence with Excellentable
Discover how to enhance your Confluence experience by creating dynamic pivot tables with Excellentable....

Leave a Reply

Your email address will not be published. Required fields are marked *