Selenium on Windows: Docker Revolution

Alexander Andryashin
Mar 12 · 7 min read

Hi there! During the last two years we in Aerokube team introduced a lot of new stuff for efficient Selenium clusters including:

  • Selenoid — a brand new Selenium protocol implementation using Docker to launch browser
  • Selenoid UI — a standalone UI for Selenoid allowing to efficiently debug running Selenium sessions
  • Ggr — an alternative to Selenium Grid approach of organizing big Selenium cluster
  • GgrUI — a lightweight daemon allowing to use Selenoid UI for the entire cluster behind Ggr
  • A set of maintained and free to use images with Firefox, Chrome, Opera and Android

Today we are going to return back to the problem of the century — how to efficiently run Selenium tests on Windows.

Why

Then the most popular Windows browsers are Firefox, Chrome, Opera and two Windows built-in browsers: Internet Explorer and Microsoft Edge. While the first three browsers have their Linux versions and thus can be packed to Docker containers, Internet Explorer (IE) and Microsoft Edge are nailed down to Windows. Usually you can’t ignore testing under IE and Edge because approximately 10–12% of users are visiting your product with these browsers.

In big companies, especially in banks and government organizations, there are a lot of legacy web-applications using ActiveX and similar technologies and thus strictly requiring Internet Explorer to work with them.

Finally, even mainstream browsers like Firefox, Chrome or Opera can have differences while comparing their Windows and Linux versions. While in the majority of cases functional testing result in these browsers is exactly the same, a small percent of platform-specific bugs exists. Which is more important — Windows and Linux have different font sets and anti-aliasing algorithms. This can lead to a bit different rendering of the same page on Windows and on Linux and front-end developers should certainly take this into consideration.

So, Windows Selenium testing is important. To better understand our new solution let’s first of all take a look at traditional Selenium approach for Windows browsers.

Traditional Selenium Approach

Being so simple traditional approach has a lot of pitfalls. First of all traditionally Windows browsers are usually deployed to long-running (i.e. mutable) virtual machines. That means that from time to time they will run out of memory, will be cluttered by browser temporary files and will suffer from browser process leaks. Then it is impossible to test in different Internet Explorer or Microsoft Edge versions on the same machine — an update automatically removes old version. That’s a shame by in 2019 we still have no way to run more than 1 parallel Microsoft Edge instance per Windows copy. For Internet Explorer this is possible but requires sophisticated techniques like using virtual desktops and running them from different user accounts to provide a reasonable level of isolation between running browser sessions.

All these limitations make Selenium testing far from being efficient and sometimes very expensive. I think most of you already understand that having short-running (i.e. immutable) containers with Windows browsers would dramatically improve testing experience. So let’s build a Docker image with Windows inside!

Running Internet Explorer and Microsoft Edge in Docker container

https://github.com/aerokube/windows-images

Just follow a step by step guide and you will obtain a working Docker image with Windows inside. A short demonstration of working images is shown in the video:

Running containers in parallel

To use Windows images with Selenoid or Moon minimal configuration file would be:

{
"internet explorer": {
"default": "11",
"versions": {
"11": {
"image": "internet-explorer:11",
"port": "4444",
"path": "/"
}
}
}
}

A possible optimization allowing to reduce disk utilization is to place virtual machine disk file to host machine and mount it to every started container. In that case your configuration file will need one more parameter called volumes:

{
"internet explorer": {
"default": "11",
"versions": {
"11": {
"image": "internet-explorer:11",
"port": "4444",
"path": "/",
"volumes":["/var/lib/selenoid/hdd.img:/hdd.img"]
}
}
}
}

Here we assume that Windows virtual machine disk file is placed to /var/lib/selenoid/hdd.img and image entrypoint script expects it to be present as /hdd.img inside running container.

What about Windows licenses?

Limitations

A short advertising of our new product

You have almost finished reading this article, so you should be interested in efficient Windows testing. We understand that some teams delegate Selenium infrastructure deployment and maintenance to external services. So we created our online Selenium testing platform called Aerokube Browsers. It already supports a wide range of browsers: Firefox, Chrome, Opera, Android emulators and Windows-only browsers: Internet Explorer and Microsoft Edge that work in Docker containers as shown in this article.

Conclusion

Still having questions?

Any More Articles?