Enabling video/screen recording for your Selenium Grid tests

Hemanth Sridhar
2 min readDec 23, 2019

One of the features that we all crave for is a recorded video of the tests we ran. It helps us in debugging as well as reporting of our bugs.

There are definitely multiple ways to do it. For starters using ffmpeg with its video recording APIs, using zalenium, selenium-grid-extras and ofcourse cloud testing platforms like browserstack, saucelabs etc.

This article will use none of these techniques but rather discuss about an underrated library called selenium-video-node. A convenient library for your framework that captures videos of your selenium nodes.

Important : The selenium-video-node library captures the video of the grid node, not the browser session. So whatever is happening in the node machine will be recorded.

Installation

  1. Download the selenium-server-standalone.jar
  2. Download the selenium-video-node.jar
  3. Start the grid hub and nodes binding the selenium-server with selenium-video-node.

Hub configuration

Node configuration

Important : If you are using windows, keep in mind to use ‘;’ instead ‘:’ while binding the jar.

If you observe the hub logs, we can see that the maxInstances value of the node is forcefully set to 1.

Coming to the code, we setup an instance of RemoteWebDriver with the required desired capabilities and search for Google.

Important :

  1. I am using Junit as my unit testing framework
  2. Maven as my build management tool
  3. Rest-Assured to make some API calls
  4. Jayway-JSONPath to parse the API response
  5. Allure for reporting

Run mvn clean test -Dbrowser=chrome and the test starts running.

Coming to the most important question, how to access the path of the video.

In order to do that, we call the one of the APIs from the selenium-video-node with the session Id. Then we use a parser to parse the response and fetch the desired key-value pair.

Allure reports code to embed the video into the reports.(If this matters)

--

--