Skript to automatically add new browser version to Selenoid browser.json

When executing Selenium tests with Selenoid the biggest chellange is to download the Selenoid browser images and keep the browser.json file up to date. On forgotten image or and image not set in the browser.json file and the tests will fail making a test chain unstable and hard to maintain.

To compare this, it is recommand to find some way of automatism to download the images and keep the browser.json file up to date. One way would be to extend a Jenkins pipeline and check the images and JSON-file before every start of the tests. But having this hard coded in the pipeline makes the Jekins job hard to maintain, That’s why it’s useful to create a small script that will perform the tasks every time it’s called. In this blog entry you can find such a tool written in Java Maven including the source code and a compiled .jar-file.

This tool will perform the following tasks:

  • Check if the browser version is already in the browser.json file
  • If the file is not present:
    • Download the image necessary for the browser version
    • Restart the Selenoid container

To call the tool use the following command:

java -jar SelenoidStarter.jar PathToBrowserJSON Browsers:Version,Browser2:Version selenoid-container-name selenoid-ui-container-name

After running the script you will see an output like this:

 Added firefox Version 83.0 to browser.json
 Added firefox Version 82.0 to browser.json
 Added firefox Version 81.0 to browser.json
 Added opera Version 68.0 to browser.json
 Added chrome Version 60.0 to browser.json

Please note, that it might take some time for the script to finish, when a lot of images for Selenoid have to be downloaded. The tool is free to use, and you can change the open source code if you want or need to.

You can download the compiled JAR-file and the source code of the tool at GitHub:
https://github.com/TestautomationPopp/Selenoid_Image_Adder_Tool