Thursday, September 6, 2018

Record Appium Exam Execution Video For Android App

| Thursday, September 6, 2018
Appium software examination execution video recording Is required when yous are executing real large tests as well as perform multitasking. Recording android device's covert video during software automation testing tin flame helps yous to detect out when Issue occurred as well as what are the steps to reproduce Issue. You tin flame Identify why your software examination Is failing past times looking In to video recording.

Before learning how to tape video of android software app automation test execution using appium, You must know how to mirror your android device's covert In PC using androidscreencast equally described In my PREVIOUS POST. Android mobile's covert sharing amongst PC Is required to tape video of android app automation examination execution. Using androidscreencast, We tin flame portion mobile covert amongst PC as well as and therefore nosotros tin flame tape PC screen's video. Let acquire how to Do It.

PREREQUISITE : Android device should hold upward connected wit PC as well as Android mobile's covert should hold upward shared amongst PC using androidscreencast.

App To Use as well as Aim To Achieve
This Is non app specific software examination example therefore yous tin flame purpose whatever app. We volition purpose hither API Demos android software app of android. Here nosotros wants to capture covert of PC therefore that nosotros tin flame tape activities of androidscreencast. We volition use ATUTestRecorder to tape video of your PC screen. In short, We volition purpose androidscreencast and ATUTestRecorder to tape video of android device's covert activities during appium examination execution.

Add ATUTestRecorder Jar In Project's Build Path
For recording your PC's covert video, You demand to download ATUTestRecorder_2.1.jar file from THIS PAGE and add together It In your project's laid upward path. View THIS POST to acquire how to add together external jolt files In project's laid upward path.

Create Test
Create novel examination file VideoReord.Java In your eclipse's projection as well as purpose bellow given examination script In It.

VideoReord.Java
package Android;  import io.appium.java_client.android.AndroidDriver;  import java.io.IOException; import java.net.URL; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.concurrent.TimeUnit; import org.apache.commons.exec.CommandLine; import org.apache.commons.exec.DefaultExecuteResultHandler; import org.apache.commons.exec.DefaultExecutor; import org.openqa.selenium.By; import org.openqa.selenium.remote.DesiredCapabilities; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import atu.testrecorder.ATUTestRecorder; import atu.testrecorder.exceptions.ATUTestRecorderException;  world degree VideoReord {  static AndroidDriver driver;  // Set path of your node.exe file. Set your path.  // Progra 1 represents Program Files folder.  String nodePath = "C:/Progra 1/Appium/node.exe";  // Set path of your appium.js file. Set your path.  String appiumJSPath = "C:/Progra 1/Appium/node_modules/appium/bin/appium.js";   ATUTestRecorder recorder;   @BeforeTest  world void setUp() throws Exception {   // Start appium server.   appiumStart();    // Get electrical flow appointment as well as fourth dimension to supply inwards recorded video name.   DateFormat dateFormat = novel SimpleDateFormat("yy-MM-dd HH-mm-ss");   Date appointment = novel Date();   // Created object of ATUTestRecorder.   // Provide path to shop videos as well as file refer format.   recorder = novel ATUTestRecorder("D:\\ScriptVideos\\", "TestVideo-" + dateFormat.format(date), false);    DesiredCapabilities capabilities = novel DesiredCapabilities();   capabilities.setCapability("deviceName", "ZX1B32FFXF");   capabilities.setCapability("browserName", "Android");   capabilities.setCapability("platformVersion", "4.4.2");   capabilities.setCapability("platformName", "Android");   capabilities.setCapability("appPackage", "io.appium.android.apis");   capabilities.setCapability("appActivity", "io.appium.android.apis.ApiDemos");   driver = novel AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);   driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);    // To outset video recording of your PC screen.   recorder.start();  }   @Test  world void performOrientation() throws InterruptedException {   // Get as well as impress electrical flow covert orientation.   System.out.println("*--*--*-- Current covert orientation Is : " + driver.getOrientation());   System.out.println("*--*--*-- Changing covert Orientation to LANDSCAPE.");   // Changing covert Orientation to LANDSCAPE.   driver.rotate(org.openqa.selenium.ScreenOrientation.LANDSCAPE);   // Get as well as impress covert orientation afterwards changing It.   System.out.println("*--*--*-- Now covert orientation Is : " + driver.getOrientation());   Thread.sleep(5000);   // Scroll till chemical cistron which contains "Views" text If It Is non visible on screen.   driver.scrollTo("Views");   // Click on Views.   driver.findElement(By.name("Views")).click();   System.out.println("*--*--*-- Changing covert Orientation to PORTRAIT.");   // Changing covert Orientation to PORTRAIT.   driver.rotate(org.openqa.selenium.ScreenOrientation.PORTRAIT);   // Get as well as impress covert orientation afterwards changing It.   System.out.println("*--*--*-- Now covert orientation Is : " + driver.getOrientation());   Thread.sleep(5000);  }   @AfterTest  world void End() throws IOException, ATUTestRecorderException {   driver.quit();   // Stop appium server when examination Is ended.   appiumStop();   // Stop video recording.   recorder.stop();  }   // This method Is responsible for starting appium server.  world void appiumStart() throws IOException, InterruptedException {   // Created object of apache CommandLine class.   // It volition outset ascendancy prompt In background.   CommandLine ascendancy = novel CommandLine("cmd");   // Add unlike arguments In ascendancy business which requires to outset appium server.   command.addArgument("/c");   command.addArgument(nodePath);   command.addArgument(appiumJSPath);   // Set Server address.   command.addArgument("--address");   command.addArgument("127.0.0.1");   // Set Port.   command.addArgument("--port");   command.addArgument("4723");   command.addArgument("--no-reset");   command.addArgument("--log");   // Set path to shop appium server log file.   command.addArgument("D://appiumLogs.txt");   // Execute ascendancy business arguments to outset appium server.   DefaultExecuteResultHandler resultHandler = novel DefaultExecuteResultHandler();   DefaultExecutor executor = novel DefaultExecutor();   executor.setExitValue(1);   executor.execute(command, resultHandler);   // Wait for xv minutes therefore that appium server tin flame outset properly earlier going for examination execution.   // Increase this fourth dimension If confront whatever error.   Thread.sleep(15000);  }   // This method Is responsible for stopping appium server.  world static void appiumStop() throws IOException {   // Add unlike arguments In ascendancy business which requires to halt appium server.   CommandLine ascendancy = novel CommandLine("cmd");   command.addArgument("/c");   command.addArgument("taskkill");   command.addArgument("/F");   command.addArgument("/IM");   command.addArgument("node.exe");   // Execute ascendancy business arguments to halt appium server.   DefaultExecuteResultHandler resultHandler = novel DefaultExecuteResultHandler();   DefaultExecutor executor = novel DefaultExecutor();   executor.setExitValue(1);   executor.execute(command, resultHandler);  } }
Test Decription
  • We accept used appiumStart() as well as appiumStop() methods to outset as well as halt appium. So appium volition hold upward started automatically wehn yous run your examination as well as yous non demand to outset as well as halt appium manually.
  • Another affair nosotros accept Implemented In script Is video recording of PC covert using ATUTestRecorder. You tin flame alter path to shop recorded video as well as video file refer equally per your requirement.
Running Test

When yous run inwards a higher house software examination using testng, Immediately keep androidscreencast Interface on transcend of the screen. Otherwise androidscreencast Interface's covert activities non recorded In video. So when your examination started execution, All the android mobile screen's activities volition display on your PC covert as well as ATUTestRecorder volition tape your PC screen.

This agency yous tin flame tape appium software examination execution video for whatever android app.

Related Posts