Record Selenium Automation Flows


         We know that automation testing entirely relies on the pre-scripted test which runs automatically to compare actual results with the expected results. This helps the tester to determine whether or not an application performs as expected. Automation testing helps to reduce the effort of the regression test suite execution of manual testers.

         Everyone is familiar with Selenium test automation for Web application and the test automation framework has the capability to generate the reports in different formats like HTML, PDF. Also, the frameworks will generate a screenshot of the UI when a test fails that depends on the configuration in the Automation Listeners. In this article I would like to share the concept of video record your automation flows; even if the test case pass or fail or skip that again depends on your configuration in the Automation Listeners.

Who will help you to record video?

         Selenium has no built-in capability to record the video of the automation flow. Here I am recording the Selenium automation flow with the help of Monte Screen Recorder Java library. The Monte media library used for processing media data. Supported media formats include still images, video, audio, and meta-data. You can record your entire automation flows for future references to share the flow as a demo to your client

Why do we need a video recording?

Video recordings of Selenium test case execution can play a major role. Not only would these help in debugging issues more efficiently, but we can also use recorded videos to show test execution activities to the client or other stakeholders. Additionally, these recorded videos can be added into the project management or defect management tool while creating bugs, which helps in understanding the bug clearly.

How can we achieve the video recording?


  • Create a Maven project.
  • Add following dependencies in pom.xml file:
    • testng
    • selenium-java
    • selenium-server
    • monte-screen-recorder (you will get it from maven repository)
  • Write sample test cases in a test class.
  • Create VideoRecordingUtility class and extends ScreenRecorder class of Monte Recorder library.

       ScreenRecorder class records mouse clicks occurring on other Java Windows running in the same JVM. Mouse clicks occurring in other JVM’s and other processes are not recorded. This ability is useful for performing in JVM recordings of an application that is being tested. This recorder uses four threads. Three capture threads for screen, mouse cursor and audio, and one output thread for the movie writer. ScreenRecorder class is a powerful class with many useful methods, here I am using two important methods of ScreenRecorder class which is start and stop. start method helps to record the screen with a defined type (in this example the type is AVI). stop method helps to stop the screen recording. Here I have created two custom methods startRecording and stopRecording. startRecording method having an argument which included in the name of the video file. You can create an object of ScreenRecorder and call start and stop methods using that object.

Following are the actual logic implementation inside startRecording method:

public static void startRecording(String methodName) throws Exception {
File file = new File(“./AutomationVideoReports/”);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int width = screenSize.width;
int height = screenSize.height;
Rectangle captureSize = new Rectangle(0, 0, width, height);
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
screenRecorder = new VideoRecordingUtility(gc, captureSize,
new Format(MediaTypeKey, MediaType.FILE, MimeTypeKey, MIME_AVI),
new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE,
CompressorNameKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, DepthKey, 24, FrameRateKey,
Rational.valueOf(15), QualityKey, 1.0f, KeyFrameIntervalKey, 15 * 60),
new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, “black”, FrameRateKey, Rational.valueOf(30)),
null, file, methodName);

Following are the actual logic implementation inside stopRecording method:

public static void stopRecording() throws Exception {

        The video recording will store in AutomationVideoReports folder. You can use startRecording and stopRecording methods based on your convenience in automation listener class, if you are using TestNG framework then you can implement ITestListener interface and use startRecording and stopRecording inside the implemented methods of ITestListener to record the video of entire test suite flow or record pass/fail/skip cases. Try to use the above logic to record your selenium automation flows and enjoy your automation.

make it perfect!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s