Running WebdriverIO tests in containers

Madhan K
TestVagrant
Published in
2 min readJun 22, 2021

As we looked at how to run test automation scripts in selenoid using 3rd party add-on actions in my previous blog. In this blog let’s dive into how to containerize WebdriverIO test automation scripts, and set up a Selenoid environment using Docker to run in local and CI environments.

The main advantage of choosing docker over any 3rd party add-on is it enables users to package an application into containers — standardized executable components that combine application source code with all the dependencies required to run the code in any environment.

Setup process

Let’s start this process by creating a Dockerfile, which is a text document that contains all the commands to build an image, docker can build an image automatically by reading the instructions present in the docker file.

The above Dockerfile will install the necessary packages and includes all the test automation source code.

Now let's create a Docker Compose file. All the instructions for running a container will be specified in this file in a YAML format.

For this example, we will use the shared compose feature which lets you share the common configurations between the compose files.

The above docker-compose file will act as a base config file for both local and CI.

Now let’s create a compose file specific for the local environment, which enables the selenoid feature of VNC and video storage.

The next step is to create compose file specific to CI environments.

Now let’s make necessary changes in wdio.conf.ts to support VNC and video storage which are specific to selenoid.

And don’t forget to volume map the browsers.json to the container running selenoid.

To manage all the commands for creating and removing containers let’s create Makefile and store all the commands in it.

Finally, let’s hook all these steps into Github Actions.

The source code of this blog post can be found here. And you can access the allure report from this link.

References:

[1] https://aerokube.com/selenoid/latest/

[2] https://aerokube.com/selenoid-ui/latest/

--

--