Hello, in the previous article, I described how to extend Selenium Grid. You can reach the tutorial in this link. Today, I am going to add  Video Recording capability into our Selenium Grid. Let’s get started Selenium Grid Video Recording Capability.

Create a Recorder for Selenium Grid Video Recording Capability

I am using monte-repack library to record videos. You can take a look at the source code in our repository. The implementation might differ from your need. That’s why I don’t want to get into its details. Maven dependency that I used is:

Changing the Proxy Implementation

I want my proxy to start recording in case there are any custom desired capabilities about recording. So I add a String value for recording request. I will check its value and start the recording.

The code below will get the value of RECORD_VIDEO capability from the TestSession object.

Then recording will start.

After the session ends, we need to stop recording by using the below code.

How to Modify Your Desired Capabilities?

Add your desired capabilities in DesiredCapabilities object as below. Then run your test, and see your Grid records video like a charm.

We create the RemoteWebDriver with our newly added Desired capability in Before Annotation. By this way, every time a driver is created a new session will be created as well.

You can implement anything in the test.

We should use quit() method of WebDriver in JUnit’s After function. By doing so Selenium terminates the session and video recording is terminated.

Important Note:

Selenium Default Proxy doesn’t know if a new test is started or not. It only knows if there’s a new session or not. You should implement your new functions according to this fact.

Full Code can be found in https://github.com/canb0/extendedSeleniumGrid

Canberk Akduygu