Thursday, 9 February 2017

SELENIUM: How To Record Selenium WebDriver Test Execution Video


How To Record Selenium Web Driver Test Execution Video:

Steps to record video for web driver test execution
We will use ATU Test Recorder to record selenium test execution videos.

1 : Download ATUTestRecorder jar file
2 : Add "ATUTestRecorder_2.1.jar" In your project's build path
3 : Create folder to store recorded videos.
You need to create folder "Recordings" In your D: drive. We will use this folder to store recorded videos.
4 : Create and run test



package com.rameshsoft.rameshselenium;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import atu.testrecorder.ATUTestRecorder;

public class ScriptRecordDemo {
          WebDriver driver;
          ATUTestRecorder recorder;

          @BeforeTest
          public void before()
          {
                   System.out.println("Before test running");
          }
          @AfterTest
          public void after()
          {
                   System.out.println("After test running");
                   driver.quit();
                  
                   recorder.stop(); 
                    
          }         
          @Test()
          public void execute() throws InterruptedException
          {
                  
                   recorder = new ATUTestRecorder("D:\\ScriptVideos\\","TestVideo-"+dateFormat.format(date),false);
                     //To start video recording.
                     recorder.start(); 
                    
System.setProperty("webdriver.gecko.driver", "C:\\Users\\ramesh\\Desktop\\java\\desk\\geckodriver-v0.11.1-win64\\geckodriver.exe");                    
driver=new FirefoxDriver();                  
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS);                  
driver.get("https://www.gmail.com");                  
driver.findElement(By.id("Email")).sendKeys("rameshsoft.selenium");                  
driver.findElement(By.id("next")).click();
Thread.sleep(2000);
driver.findElement(By.id("Passwd")).sendKeys("12345");
driver.findElement(By.id("signIn")).click();
                  
driver.quit();
          }

}
 

No comments:

Post a Comment