logo logo

Zalenium – Dockerized Selenium Grid Infrastructure

Zalenium

Zalenium is a highly flexible and auto-scalable Docker container-based Selenium Grid Infrastructure. It has the feature to spin up selenium docker containers instantly as nodes without any manual intervention. It also has a video recording feature that can be viewed using a VNC player which is hosted within the live preview board.

The main objective of Zalenium is to have a disposable and flexible Selenium Grid Infrastructure for everyone and in an automated fashion.

Selenium Grid Challenges 

  • Maintaining a stable grid to run UI tests across browsers
  • Maintaining it over time
  • Costs more when it comes to the maintenance of many VM machines
  • Provide features for all browsers and platforms

Thanks to Diego Molina for creating this wonderful solution, Zalenium provides docker-selenium nodes that are created on-demand and disposes of itself after test execution without giving any commands. With this, the test cases run very faster as the browsers are running in the local machine.

Zalenium Infrastructure

 

 

Get Started 

Pre-requisites

  1. Basic docker understanding
  2. Test Automation framework with Selenium-Grid implemented
  3. Docker v1.11.1 or above

Run

Step 1:

In mac, open Terminal (In Windows, open Powershell)

First, pull selenium docker image –

docker pull elgalu/selenium

Step 2:

Then pull Zalenium docker image –

docker pull dosel/Zalenium

Step 3:

After the two images are pulled, use the below command to start the Selenium-Grid via Zalenium and 2 docker-selenium nodes will be instantiated –

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

Step 4:

After running the above command and once the grid is started, launch below URL to view the grid console. You will be able to see two containers started by default –

http://localhost:4444/grid/console

Step 5:

To view the Dashboard, type the below command to launch the Zalenium Dashboard to view the test results and the recording video –

http://localhost:4444/dashboard/

Zalenium

You can view LIVE execution via VNC viewer

Step 6:

We have now started the Zalenium with a HUB and two NODES successfully.

Step 7:

All we need to do now is, in the test automation framework, add the RemoteWebDriver URL as –

http://localhost:4444/wd/hub

Example (Java) –

RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), desiredCapabillities);

When running the test suite, the real magic happens ✨ For each and every test, a unique docker container will be created and assigned, and the test gets executed. The beauty is, all tests will execute in parallel.

Step 8: View the Dashboard once the test execution gets completed. You will be able to view the video as well –

Zalenium

Benefits of using Zalenium

  1. Stable and scalable selenium grid infrastructure in no time.
  2. Everything happens within the local machine. Hence, there is no need for separate laptops or VMs.
  3. Tests can be executed with various viewports by defining width and height. With this, the mobile version can also be tested without any special efforts or tools.
  4. No special maintenance required for Hubs and Nodes.
  5. Reduces the test execution time up to 90%.
  6. Easy integration with third-party tools like BrowserStack & Sauce Labs.
  7. CI/CD ready.
  8. Automatic disposal of docker containers.
  9. Video recordings of tests in headless mode.
  10. No special network settings required except the proxy settings as the containers take it from Hub (host machine).
  11. Highly configurable with many capabilities (check the Configuration Parameters in Zalenium Website).

Reference: https://opensource.zalando.com/zalenium/

About the author

Giridhar Rajkumar

With his 10+ years of experience in IT industry, Giridhar has worked with multiple customers in the UK, EU, India and Latin America for a successful transformation in Test Automation & DevOps. He is a successful trainer and trained over 2000+ professionals in Test Automation, DevOps and BDD Concepts.

Comments

10 2 comments
  • PraveenKK December 17, 2019, 4:13 am

    HI
    Thanks for writing such a good and detailed blog. I am facing one issue with respect to the command mentioned in step 3. Could you pls check and let me know?
    PS C:\WINDOWS\system32> docker run –rm -ti –name zalenium -p 4444:4444 \
    C:\Program Files\Docker\Docker\Resources\bin\docker.exe: invalid reference format.
    See ‘C:\Program Files\Docker\Docker\Resources\bin\docker.exe run –help’.
    PS C:\WINDOWS\system32>

  • Oomkar Pandit May 11, 2020, 2:10 pm

    Hi @PraveenKK, if you use this command it will work-
    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

Leave a Reply

FacebookLinkedInTwitterEmail