Getting Started with Zalenium: Docker-based Selenuim Grid | Hacker Noon

image

Zalenium is a container-based Selenium Grid featuring video recording, live preview, rudimentary authentication, and a dashboard. The integration of Docker and Kubernetes makes Zalenium an appealing choice for setting up Selenium-based infrastructure.

Why Zalenium is a great choice to manage the selenium Grid?

Selenium Grid consists of “Hub” and “Nodes”. Nodes are the configurations that we want to test, such as Windows 10 with Chrome. We use RemoteWebDriver to point our tests to the HUB, which then routes them to the appropriate Node if one is available or queues them.

It’s always difficult to set up a selenium grid with nodes since you need to know how many nodes to set up.  If there are too few nodes, your tests will begin to time out, and you will need to add more nodes. A large number of nodes causes a waste of machine resources.  Another challenge is to maintain nodes and keep up with the latest browser versions.

How does it sound to have a scalable and dynamic grid that adds nodes as needed and disposes them after the test is finished?

Introducing Zalenium – Selenium Grid extension which scales your local grid dynamically with docker containers to run tests in Firefox or Chrome. You can also redirect your tests to cloud grids like Sauce Labs, BrowserStack, TestingBot, CrossBrowser Testing, LambdaTest.

Let’s try Zalenium:

1. Install Dockerdesktop on your system (if not already have yet)

https://docs.docker.com/docker-for-windows/install/

2. Check docker installation using the command: docker -v

image

3. Pull below docker images by using these commands:

docker pull elgalu/seleniumdocker pull dosel/zalenium
image
image

4. Check the docker image by using the command: docker images

image

5. Run Zalenium by below command on cmd:

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
image

6. After successfully running the previous commands, check if containers are up: docker ps

image

7. Now you can access below URL’s

Grid console – http://localhost:4444/grid/console
Zalenium Live Preview – http://localhost:4444/grid/admin/live
Dashboard – http://localhost:4444/dashboard/ after
running your first test

image
image

8. Run the selenium script by modifying the code as below:

image

9. You can watch the application running live by Zalenium live Preview:

image

10. After execution you can view the video of the test from the Zalenium Dashboard:

image

Find out more under complete documentation: 

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

Also published here by Tahera Firdose.

Tags

Join Hacker Noon