Video recording the Selenium Automation scripts 

Its been a long time since I have posted an article, been very busy with work. So, here is an article about video recording the automation scripts that you running.

I have used a third part library called “monte.media” to record the testing. This is done when there are issues. The recorded video is attached to the Jira ticket for the developer to see the steps and also know the issue.

Here are the libraries you need import.

import org.monte.media.Format;
import org.monte.media.math.Rational;
import org.monte.screenrecorder.ScreenRecorder;
import static org.apache.commons.io.FileUtils.copyFile;
import static org.monte.media.AudioFormatKeys.EncodingKey;
import static org.monte.media.AudioFormatKeys.FrameRateKey;
import static org.monte.media.AudioFormatKeys.KeyFrameIntervalKey;
import static org.monte.media.AudioFormatKeys.MIME_AVI;
import static org.monte.media.AudioFormatKeys.MediaType;
import static org.monte.media.AudioFormatKeys.MediaTypeKey;
import static org.monte.media.AudioFormatKeys.MimeTypeKey;
import static org.monte.media.VideoFormatKeys.*;</code>

//Here is the method to start the recording
public void startRecording() throws Exception {
        GraphicsConfiguration gc = GraphicsEnvironment
                .getLocalGraphicsEnvironment()
                .getDefaultScreenDevice()
                .getDefaultConfiguration();
        this.screenRecorder = new ScreenRecorder(gc,
                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);

        this.screenRecorder.start();
    }

//Here is the method to stop the recording
  public void stopRecording() throws Exception {
        if (record.equalsIgnoreCase("Yes")) {
            this.screenRecorder.stop();
        }
    }

For the video to work make sure you use both the startRecording and stopRecording methods.

Useful links: http://www.randelshofer.ch/monte/
http://massol.myxwiki.org/xwiki/bin/view/Blog/ScreenRecordingForSelenium2


Author: Pavandeep Puddupakkam on May 24, 2013
Category: Java, WebDriver
Tags: , ,
Selenium Webdriver Forum -The Online Community for Selenium Webdriver and Selenium RC Users and Professionals
2 responses to “Video recording the Selenium Automation scripts”
  1. Uma says:

    Hello, Monte recorder is works fine in my machine, when i had put the code in Jenkins server, if the machine where the job is running is not logged in, the recorded video is just black, Thanks in advance for the help

  2. Pavandeep Puddupakkam says:

    You can add the external jar file MonteScreenRecorder.jar from http://www.randelshofer.ch/monte/

    In intellij you can add the external jar file as under.

    File -> Project Structure (ctrl + shift + alt + s ) -> Module -> Dependencies -> add… -> Project Library -> Attach Jar

Leave a Reply

Last articles