Engineering Productivity is an area in Zalando where our main goal is to help other teams test their products by providing great tools and services. For UI testing execution, we offer teams a mix of internal and external tools. Some teams use docker-selenium, a dockerized Selenium Grid, and other teams use Sauce Labs.
Each tool has its own advantages and disadvantages, but they fulfill our needs and complement each other. We thought it would be a great idea to mix them, so we can run tests quickly in Chrome/Firefox, and when we need other browsers, use Sauce Labs. Chrome and Firefox are the most used browsers for testing at Zalando, while Safari and IE/Edge come afterwards.
We decided to create Zalenium, a tool to help you scale your local grid dynamically with Docker containers. It uses docker-selenium to run your tests in Firefox and Chrome locally, and when you need a different browser, your tests get redirected to a cloud testing provider.
We know how complicated it is to have a stable Selenium Grid with enough capabilities to cover all browsers and platforms, and how hard it can be to maintain it over time. With this approach, you can run your UI tests faster with Firefox and Chrome due to the fact that they are running on a local grid, on a node created from scratch and disposed of after the test finishes. Whenever you need a capability that cannot be fulfilled by docker-selenium, the test gets redirected to a cloud testing provider – so far we have integrated Sauce Labs, BrowserStack and TestingBot.
This highlights Zalenium's main goal: to allow anyone to have a disposable and flexible Selenium Grid infrastructure.
This image shows how Zalenium works conceptually:
Let’s dive into how to use it.
First, pull the following Docker images (may take some minutes)
docker pull elgalu/selenium docker pull dosel/zalenium
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:
export SAUCE_USERNAME= export 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
And that’s it! Check your local grid and run some tests.
After running your tests, you will notice that videos are recorded if you check your local “tmp/videos” folder. You can also see the tests running in the live preview feature. Check out further startup options here (like screen sizes, using BrowserStack or TestingBot, etc.).
With Zalenium, we are giving teams the opportunity to use their resources in a more efficient way. By combining Zalenium and Sauce Labs, teams can run UI tests during development much faster, and before releasing they can do a final check using the additional capabilities provided by Sauce Labs. With this integration, our test suites operate with greater speed, since most of the tests run on local Firefox/Chrome nodes, and we use the cloud testing service we pay for in a smarter way.
Zalenium is open source, so please feel free to try it and use it as part of your infrastructure. Do not hesitate to create an issue asking for help or suggest features, or contribute in any way you would like.