Zalenium is a flexible and scalable container based Selenium Grid, with video recording, live preview, basic auth & a dashboard. Moreover, it has out-of-the-box Docker and Kubernetes integration. This fact makes Zalenium an attractive choice to get Selenium based infrastructure up and running.
Zalenium provides docker images (Hub + Nodes) with the latest browser drivers, browsers, and tools (for any language bindings) required for Selenium automation. The containers created from these images can be scaled-up with simple CLI commands.
This is a Selenium Grid extension to scale your local grid dynamically with docker containers. It uses docker-selenium to run your tests in Firefox and Chrome locally, if you need a different browser, your tests can get redirected to a cloud testing provider (Sauce Labs, BrowserStack, TestingBot, CrossBrowserTesting, LambdaTest).
Why to use Zalenium?
Zalenium was created to solve the widespread issue that a lot of people have when you have some tests, and you want to start running them in parallel.You start by getting into Selenium Grid but encounter roadblocks pretty quickly when trying to scale.
The most common issue is that you need to start to keep up with the release of the new Selenium Versions and to have them in synchronization with the browser releases and the browser drivers release like chrome driver, gecko driver and so on.
You end up spending a lot of time into configuring all these moving parts.
Zalenium was created to handle these issues for you automatically.
Zalenium Setup:
1.Ensure that you have latest docker engine is running. You can get the instructions here on installing docker.
2.After installing docker ,check with below command:

3. Pull below docker images by below command.
docker pull elgalu/selenium
docker pull dosel/zalenium

4.Check the docker images by below command:

5. Run Zalenium by below command on cmd:
docker run --rm -ti --name zalenium -p 4444:4444 -p 5555:5555 -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/videos:/home/seluser/videos dosel/zalenium start

After successfully running the previous commands, you can check:

Now you can access below :
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



Run the selenium script by modifying the code:
DesiredCapabilities dc = DesiredCapabilities.firefox(); //or dc = DesiredCapabilities.chrome();
RemoteWebDriver driver=new RemoteWebDriver(new URL("http://HostName:4444/wd/hub"), dc);
driver.get("https://www.google.com");
You can live watch the application running by Zalenium live Preview:

You can Zoom the Zalenium live Preview:

after execution you can watch the video of the test from the Zalenium Dashboard:

By default, our Selenium grid will have 1 Chrome and 1 Firefox container. If you need more, say 3 chrome containers, 2 firefox then use below arguments.
docker run --rm -ti --name zalenium -p 4444:4444 -p 5555:5555 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/videos:/home/seluser/videos \
dosel/zalenium start --chromeContainers 3 --firefoxContainers 2
Test Configuration Options:
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(CapabilityType.BROWSER_NAME, BrowserType.FIREFOX);
desiredCapabilities.setCapability(CapabilityType.PLATFORM_NAME, Platform.LINUX);
//Test Name
desiredCapabilities.setCapability("name", "myTestName");
//Build Name
desiredCapabilities.setCapability("build", "myTestBuild");
//Idle TimeOut
desiredCapabilities.setCapability("idleTimeout", 150);
//Screen Resolution
desiredCapabilities.setCapability("screenResolution", "1280x720");
//Disable Video
desiredCapabilities.setCapability("recordVideo", false);
//Time Zone
desiredCapabilities.setCapability("tz", "America/Montreal");
//Set browser language (works only with Chrome)
DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("lang=en_GB");
desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options);
//Test File Name Template
Adding a testFileNameTemplate capability will save logs and video recording with file name format you prefer. Resulting file name can have invariable and variable text. You can find the list of variable text below:
{proxyName} - Zalenium|SauceLabs|BrowserStack|LambdaTest
{testName} - The one added as "name" on capabilities, otherwise a session key
{browser} - The browser name
{platform} - OS where test runs
{timestamp} - Timestamp of test initialization
{testStatus} - Test result: COMPLETED|TIMEOUT|SUCCESS|FAILED
E.g. myID_{browser}_{testStatus} will result on video file name as "myID_chrome_COMPLETED.mp4".
Default file name template is: {proxyName}_{testName}_{browser}_{platform}_{timestamp}_{testStatus}
Example code in Java for the capability testFileNameTemplate.
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(CapabilityType.BROWSER_NAME,BrowserType.FIREFOX);
desiredCapabilities.setCapability(CapabilityType.PLATFORM_NAME, Platform.LINUX);
desiredCapabilities.setCapability("testFileNameTemplate", "myID_{browser}_{testStatus}");
Integrating with Cloud Testing Platforms:
- Yet another cool feature of zalenium is – It can be integrated with cloud based testing solutions like BrowserStack/SuaceLabs.
- Any incoming request to the hub is verified by zalenium – If it can create a container for the request, It starts a container and runs the test.
- Otherwise, the test gets executed at the cloud testing platforms.
Sauce Labs:
export SAUCE_USERNAME=[your Sauce Labs username]
export SAUCE_ACCESS_KEY=[your Sauce Labs access key]
docker run --rm -ti --name zalenium -p 4444:4444 -p 5555:5555 \
-e SAUCE_USERNAME -e SAUCE_ACCESS_KEY \
-v /tmp/videos:/home/seluser/videos \
-v /var/run/docker.sock:/var/run/docker.sock \
dosel/zalenium start --sauceLabsEnabled true
BrowserStack:
export BROWSER_STACK_USER=[your BrowserStack username]
export BROWSER_STACK_KEY=[your BrowserStack access key]
docker run --rm -ti --name zalenium -p 4444:4444 -p 5555:5555 \
-e BROWSER_STACK_USER -e BROWSER_STACK_KEY \
-v /tmp/videos:/home/seluser/videos \
-v /var/run/docker.sock:/var/run/docker.sock \
dosel/zalenium start --browserStackEnabled true
For more information on Zalenium, please check here
References:
https://opensource.zalando.com/zalenium/
https://github.com/zalando/zalenium
https://opensource.zalando.com/zalenium/#usage
Categories: Out of Box, Selenium
The problem I am facing is that the dosel/zalenium is not using the elgalu/selenium image instead it is using the latest image that is present, Please let me know how to make zalenium select the elgalu/selenium image
Since these are just containers we don’t have any memory.. So if user wants to run test case wherein we want to upload a file or download and validate that file on zalenium..
How to do that? is there any way we can configure volumised docker in grid?
Please help!
yes you can use volume in docker container to manage the data. for more detail on volume -https://www.javatpoint.com/what-is-docker-volume