paint-brush
A Successful Selenium Parallel Testing With Zaleniumby@div23
562 reads
562 reads

A Successful Selenium Parallel Testing With Zalenium

by DivyaMay 20th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Zalenium - a flexible, scalable container based Selenium Grid with features like video recording, live preview, basic authentication and a dashboard. Its Out-of-the-Box Docker makes it easy to run a Selenium based infrastructure smoothly. The other objective was to bring down the cost of remote servers with dockerization in place. We were able to run all our tests parallelly in different dockerised containers in our local machine itself, and there was no need of VMs or separate physical machines.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - A Successful Selenium Parallel Testing With Zalenium
Divya HackerNoon profile picture

Zalenium - a flexible, scalable container based Selenium Grid with features like video recording, live preview, basic authentication and a dashboard. Its Out-of-the-Box Docker makes it easy to run a Selenium based infrastructure smoothly.

We at Pickyourtrail, run a lot of automation frameworks with Selenium. But since our Software Infrastructure got dockerized, we also thought to migrate our automation framework to docker to build CI/CD pipeline in Jenkins. Moreover, we were finding it difficult to run our Selenium tests parallel to our local system. We were exploring different ways to address the above issues and finally decided to implement Zalenium within our automation framework. The other objective was to bring down the cost of remote servers with dockerization in place.

How we tried solving it?

We explored the implementation of the Zalenium library to better understand its usage and how we can re-use it within our framework to attain our objective.

From our understanding, we got to know that it extensively depends on Selenium Docker images and Zalenium community has built in a wrapper around the Selenium docker image to bring up Selenium Grid with video recording, live preview and dashboard capabilities.

From our experience, below are the steps that needs to be followed to set up Selenium Grid in few seconds.

Prerequisites

  • Docker version >= 1.11.1 (probably works with earlier versions, not tested yet).
  • Make sure that docker info works without errors.

Once the Prerequisites are set, execute the below docker commands to set up Selenium Grid.

# To Pull docker-selenium
    docker pull elgalu/selenium
# To Pull Zalenium
    docker pull dosel/zalenium
# To Run it Zalenium
    docker run --rm -ti --name zalenium -p 4444:4444 \
      -v /var/run/docker.sock:/var/run/docker.sock \
      -v /tmp/videos:/home/seluser/videos \
      --privileged dosel/zalenium start

Once the above steps are done, we need to point our tests to http://localhost:4444/wd/hub in our automation framework. This URL should be set as the argument to RemoteWebDriver along with DesiredCapabilities.

# To Stop Zalenium
    docker stop zalenium

Once the above steps are done, below are the URLs which will help us to view the execution status.

a) Grid Console:

http://localhost:4444/grid/console

b) Grid Execution console:

http://localhost:4444/grid/admin/live?refresh=10

where refresh value can be altered as per our need in the above URL.

c) Test execution dashboard which will contain all our recorded tests:

http://localhost:4444/dashboard/

The above commands will help us to create a basic version of the dockerized Selenium Grid. Apart from this, there are different configuration parameters that can be used along with the above command to fit our requirements. Below are the configuration parameters that we have used.

More Configuration Parameters

Instead of running the above commands everytime, I have written a bash script that will pull all the necessary docker images and the configuration parameters for setting up Selenium Grid.

GitHub Repo for the same:

This repo will contain detailed README.md which will guide you in setting up scalable Selenium Grid Infrastructure.

Conclusion:

With Zalenium, we were able to resolve the major constraints that were faced in our previous automation framework. Listing a few of them.

  • Our framework was also dockerized and we were able to bring up scalable and stable Selenium grid infrastructure in no time.
  • Since it has been dockerized, we were able to build CI/CD easily.
  • It helped us to bring down the execution time by 80% Second, we were able to run all our tests parallelly in different dockerised containers in our local machine itself, and there was no need of VMs or separate physical machines.
  • We were able to visually see the tests running in dockerised containers, and we were also able to record the tests. This was helping us in debugging the errors easily.
    Second, there was no need to maintain the Grid infrastructure from our end.
  • We were able to configure the Grid Infrastructure using different configuration parameters available in Zalenium.

References for Zalenium definition and functionality are taken from https://opensource.zalando.com/zalenium/.