Reading Time: < 15 minutes

What’s up Guys! Welcome to automationcalling.com

Today, I come up with topic of how to automate Cross Browsers/Parallel Automation test on Local, Remote and Cloud using TestNG and Zalenium, end of this article I will provide my sample framework which helps you to reduce massive time for taking test execution as well as options to split your tests based on your need for quick or early feedback.

What is Zalenium?

Simple Answer is, a simple way to create a dynamic and disposable selenium grid for cross browser automation test in parallel.

Zalenium_architecture

Zalenium 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, it’s possible to configure Cloud based solution like Sauce Labs, BrowserStacks, TestingBots.

Zalenium’s main goal is: to allow anyone to have a disposable and flexible Selenium Grid infrastructure.

Problem Statements:

  • Traditional Grid Solution: Probably physical and virtual machine required to create nodes that need to be registered in Hub.
    • Automation test gets interrupted due to network issues.
    • Multiple browser versions may require multiple Physical and VMs.
    • Hard to setup and difficult to maintain.
  • Cloud options: Expensive to pay for concurrency, VPN connection, complicated and sometime test execution is slow for creating machine dynamically.
  • The above points can be addressed in  docker-selenium but it supports chrome and firefox how about other browser types? or combination of Remote as well as cloud?
  • No stable grid to run UI test with Selenium.

To achieve all, I’m going to explain how to setup Zalenium in your local box to make your test faster and have a disposable and flexible Selenium Grid infrastructure.

Getting Started:

Prerequisites:

  • Must have Microsoft Windows 10 Professional or Enterprise 64-bit for Docker Community Edition. For Windows Server 2016, you must have Docker Enterprise Edition.
  • Good to have Administrator Access.
  • Minimum Docker engine running, version >= 1.11.1

Docker Installation:

  • Register and download installer from https://store.docker.com/editions/community/docker-ce-desktop-windows
  • Make sure Virtualization is enabled in BIOS setting
  • Make sure Hyper-V and its sub-folders are enabled
  • Make sure your docker daemon is running
  • Once installed, supply command docker –version, for eg.,

dockerversions

Starting Zalenium:

To setup Zalenium, first we should pull docker-selenium followed by Zalenium

# Pull docker-selenium
  docker pull elgalu/selenium

  # Pull Zalenium
  docker pull dosel/zalenium

For above commands, it pulls images from docker registry for both docker-selenium and Zalenium.

To verify images are downloaded successfully, supply the following command

docker images

which shows like below snapshot.

dockerimages

Start Zalenium, without any cloud testing provider enabled:

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

Start Zalenium with Sauce Labs enabled:

Remember: For SauceLab, you must add environment variable for the following parameter before run docker command

  • SAUCE_USERNAME
  • SAUCE_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

After successfully started Zalenium: Please refer the following urls:

Grid Console: http://localhost:4444/grid/console which actually shows configured browsers and OS details

Zalenium_Grid

Live Dashboard: http://localhost:4444/grid/admin/live, this will help us to view how our test running in parallel on different brorwsers. Please refer the below video which was actually achieved in our automation framework.

Zalenium Dashboard: localhost:4444/dashboard/ This is the place where All test Videos, logs (Selenium Logs) are archived. The below video was run during parallel automation in Sauce Labs.

To Play with Framework:

  1. Clone the framework https://github.com/automationcalling/seleniumparallel.git
  2. Make sure to follow “Starting Zelenium” entire section in this page.
  3. Open Intellij or Eclipse and Run “TestSuites.xml” which run test suites parallel in Local, Remote as well as Cloud (change parameters if it’s required)

Note: Point No.3 can also be possible to configure in Jenkins for Local, Remote and Cloud options.

Conclusion:

Zalenium is an excellent option and approach to implement your existing automation process, which actually speed up your test exection and also provide Stable Grid to run your UI automation for Chrome and Firefox. It’s also possible to add multiple browser version or nodes of Chrome/Firefox in docker images based on your requirements.

It’s also possible to configure other browsers by cloud providers for eg., Safari browsers or different Microsoft Edges which can be achieved in Sauce Labs, TestingBot etc.,,

Credits:

https://github.com/zalando/zalenium

https://github.com/SeleniumHQ/docker-selenium

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s