Record a Video of Your TestCases Using Selenium Webdriver+ Java

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.


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s