Pages

selenium-scenario-vedio-making

1) How to make vedio of selenium scenario ?


First we download MonteScreenRecorder.jar file


##### Sample Demo Program #####

import static org.monte.media.FormatKeys.EncodingKey;
import static org.monte.media.FormatKeys.FrameRateKey;
import static org.monte.media.FormatKeys.KeyFrameIntervalKey;
import static org.monte.media.FormatKeys.MIME_AVI;
import static org.monte.media.FormatKeys.MediaTypeKey;
import static org.monte.media.FormatKeys.MimeTypeKey;
import static org.monte.media.VideoFormatKeys.CompressorNameKey;
import static org.monte.media.VideoFormatKeys.DepthKey;
import static org.monte.media.VideoFormatKeys.ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE;
import static org.monte.media.VideoFormatKeys.QualityKey;

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

import org.monte.media.Format;
import org.monte.media.FormatKeys.MediaType;
import org.monte.media.math.Rational;
import org.monte.screenrecorder.ScreenRecorder;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;


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

videoRecord.startRecording(); //Started recording
System.setProperty("webdriver.chrome.driver", "F:/chromedriver/chromedriver.exe");
driver=new ChromeDriver();
driver.get("http://www.keeplearners.blogspot.in");
driver.manage().window().maximize(); 
driver.findElement(By.id("selenium-vedio-making")).click();
System.out.println("Navigating to selenium-scenario-vedio-making");
Robot r= new Robot();
r.mouseWheel(4);

Thread.sleep(2000);

videoRecord.stopRecording(); //Stopped recording
driver.quit();
}
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();
}



public void stopRecording() throws Exception
{
this.screenRecorder.stop();
}
}

After executing the program, you will get vedio of the executed scenario in C: drive (path: C:\Users\**\My Videos folder)


Please comment below to feedback or ask questions.




No comments:

Post a Comment

Please comment below to feedback or ask questions.