Record a Video of Your TestCases Using Selenium Webdriver+ Java

images (3)

We know how to capture a screenshot of your Automated TestCases, How about a video ?? This post helps you to record your screen when you conduct automation test. This is very simple to record/video test cases.It also helps you to debug if any test script went wrong.

Please follow the steps to record your screen

Step 1. You have to download the MonteScreenRecorder.jar from Here.

Step 2. Extract it and add jar to buildpath under your project Also add your selenium required jars. Step 3. Prepare your test cases which needs to be automated.

Step 4. Need to call “screenRecorder.start()” methods at starting of your test scripts and “screenRecorder.stop()” at the end of execution. Just follow the below code for the reference.

import static;
import static;
import static;
import static;
import static;
import static;
import static;
import static;
import static;
import static;

import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Robot;

import org.monte.screenrecorder.ScreenRecorder;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class VideoRecorderclass {
public ScreenRecorder screenRecorder;
WebDriver driver;
public void test01() throws Exception {
VideoRecorderclass videoRecord = new VideoRecorderclass();

videoRecord.startRecording(); //Started recording
driver=new FirefoxDriver();
Robot r= new Robot();

System.out.println(“Password was typed”);

videoRecord.stopRecording(); //Stopped recording

public void startRecording() throws Exception
GraphicsConfiguration gc = GraphicsEnvironment

this.screenRecorder = new ScreenRecorder(gc,
new Format(MediaTypeKey, MediaType.FILE, MimeTypeKey, MIME_AVI),
new Format(MediaTypeKey, MediaType.VIDEO, EncodingKey, 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)),

public void stopRecording() throws Exception

That’s it. You will see the video file in your C drive mostly..!  You can play it using VLC player.


25 thoughts on “Record a Video of Your TestCases Using Selenium Webdriver+ Java

  1. Praveen Ambi July 15, 2015 / 11:48 am

    Where we can see the recorded videos i.e where those videos will be stored ?
    Kindly help

    Thanks in advance
    Praveen A


    • charan163 July 15, 2015 / 2:31 pm

      It will store in C:\Users\user\Videos
      else you can search in the ‘Start-Menu’ just type “ScreenRecording”


      • Anonymous June 13, 2016 / 1:05 pm

        I have downloaded MonteMedia and added all the Jars….but


  2. Rajendra kumar July 15, 2015 / 10:28 pm

    Is this screen recording or browser session recorder. Will this work when we run tests in parallel?


    • charan163 July 15, 2015 / 11:02 pm

      It will just record your screen.What ever happens while automating,it will capture all the gesture including mouse hovering actions.And also moves of cursor…!


  3. Mithilesh July 19, 2015 / 1:02 pm

    Video is not being recorded if the test case is failed. A blank file is being created in case of failed scenarios


    • charan163 July 19, 2015 / 4:50 pm

      No, The code doesnt work in that way.It will record everything.Code dont even know which are the passed testcases and which are the failed testcases.Maybe your logic went wrong.


  4. Anonymous March 4, 2016 / 6:46 am

    This piece of code really helped. Thank you :)

    Liked by 1 person

  5. Deeb Andrawis Andrawis April 20, 2016 / 3:38 pm

    is there any what to capture every browser session ? to use it when we run tests in parallel


  6. Anonymous June 13, 2016 / 1:09 pm

    I have downloaded MonteMedia and added all the Jar files into my project, but I am getting The method startRecording() is undefined for the type when I mouse hover the startRecording.
    ex: VideoRecorderclass videoRecord = new VideoRecorderclass();
    videoRecord.startRecording(); //Started recording


  7. Krunal September 6, 2016 / 6:14 pm

    Its very Good.
    I have tried this MonteScreenRecorder and its working fine on my machine.
    But I want to record client machine screen where test cases execute.
    So is there any other way with that I can record client machine screen.


  8. Anonymous February 21, 2017 / 4:05 pm

    I have tried this code but its not working,can any one help m to record my test case using selinium.


    • Hari Charan February 21, 2017 / 5:42 pm

      Please let me know the exception you’re facing


  9. Marco Sanabria Alfaro April 20, 2017 / 10:05 am

    Does it work for tests cases running in parallel?


    • Hari Charan April 20, 2017 / 2:59 pm

      You may not get individual recording on Parallel execution. It will record everything which is on Focus


  10. Marco Sanabria Alfaro April 20, 2017 / 10:06 am

    Also, does it work with Selenium RemoteWebDriver?


  11. Ravi Kumar Karanam February 1, 2018 / 10:07 pm

    Hi, This is very excellent topic. Is it possible to record the screen when browser is running in headless mode. Also, do you have code for c#


  12. Ifeoma Emodi March 5, 2018 / 9:38 pm

    I have a situation am not using the jar but rather a pom.xml, I have added the dependencies. I am . new to automation was looking for something like this, although my test is not running parallel but my setup is slightly different from your’s. Do you have a private email I can send you an email to please


Leave a Reply

Please log in using one of these methods to post your comment: 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