Selenium, browser and test library version incompatibility issues can be quite tricky. But they don’t have to be. Check out and learn how to do it right!
Everyone loves Selenium. And why not, it’s great. Yet, I recall moments of complete frustration when browser drivers fail and I just can’t quite recall the correct version of Firefox to work with a version of Selenium. Don’t get me wrong, I absolutely love version control and virtual environments. In fact, I like virtualenvwrapper so much that I use it even when I am not working with Python. Just because I can and because I like navigating projects with workon. It sets my gopath, path and env. It’s good - trust me. Even though, I plead guilty of sometimes being satisfied with the working system and forgetting to lock down browser or tool versions.
Honestly, browser and tool version control is a solvable problem. You just launch the grid, attach all your favorite browsers, disable updates and install tools with locked versions. Ok, cool. Once you do it, you can relax a bit. Until you want some updates or until you are told that also older versions of browsers must be tested. Then you’re really facing the legendary problem that I know as version matrix.
At this point, the versions of Selenium, browsers and other related tools like Robot Framework and Selenium2Library are bustling in your mind, gently pushing a solitary tear into your eye. Before we get all too emotional here, though, let me tell you something comforting: the time of version incompatibility is over. Furthermore, running different versions of browsers is a robust and swift operation that can in most cases be launched in minutes or even seconds.
To be more accurate, I could reduce the previous statement to “partially obsolete”. The answer is to pack browsers as Docker containers and launch them together with Selenium hub with a single Docker-compose command. Before you get all too excited, I’d recommend checking out Docker Selenium from Github. However, if you’re running out of patience you can move on to Running Eficode Example Already.
In a nutshell, docker hub has images for different versions of Selenium and compatible browser nodes.
Once you connect the nodes, you can run tests with different browsers.
In my opinion, the coolest way to do it in practice is to pack different versions of infra into Docker-compose files and launch them dynamically when you need them:
After launching infra, you can run tests for individual browsers or with all browsers at once:
If you want to monitor the test execution, use debug images and connect with vnc. Inside you’ll find the completely functional browsers and you can also use the developer tools.
Pretty cool, huh? Don’t forget that you can always extend the core infra with virtual machines if you need to test more exotic browsers like Internet Explorer or Safari.