Appium software examination execution video recording Is required when you lot are executing really large tests too perform multitasking. Recording android device's hide video during software automation testing tin helps you lot to honour out when Issue occurred too what are the steps to reproduce Issue. You tin Identify why your software examination Is failing yesteryear 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 hide In PC using androidscreencast every bit described In my PREVIOUS POST. Android mobile's hide sharing amongst PC Is required to tape video of android app automation examination execution. Using androidscreencast, We tin percentage mobile hide amongst PC too and hence nosotros tin tape PC screen's video. Let larn how to Do It.
PREREQUISITE : Android device should hold out connected wit PC too Android mobile's hide should hold out shared amongst PC using androidscreencast.
App To Use too Aim To Achieve
This Is non app specific software examination illustration hence you lot tin purpose whatever app. We volition purpose hither API Demos android software app of android. Here nosotros wants to capture hide of PC hence that nosotros tin 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 hide activities during appium examination execution.
Add ATUTestRecorder Jar In Project's Build Path
For recording your PC's hide video, You demand to download ATUTestRecorder_2.1.jar file from THIS PAGE and add together It In your project's fix path. View THIS POST to larn how to add together external jounce files In project's fix path.
Create Test
Create novel examination file VideoReord.Java In your eclipse's projection too 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; populace 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 populace void setUp() throws Exception { // Start appium server. appiumStart(); // Get electrical flow appointment too fourth dimension to furnish 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 too 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 maiden of all video recording of your PC screen. recorder.start(); } @Test populace void performOrientation() throws InterruptedException { // Get too impress electrical flow hide orientation. System.out.println("*--*--*-- Current hide orientation Is : " + driver.getOrientation()); System.out.println("*--*--*-- Changing hide Orientation to LANDSCAPE."); // Changing hide Orientation to LANDSCAPE. driver.rotate(org.openqa.selenium.ScreenOrientation.LANDSCAPE); // Get too impress hide orientation later on changing It. System.out.println("*--*--*-- Now hide orientation Is : " + driver.getOrientation()); Thread.sleep(5000); // Scroll till chemical ingredient 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 hide Orientation to PORTRAIT."); // Changing hide Orientation to PORTRAIT. driver.rotate(org.openqa.selenium.ScreenOrientation.PORTRAIT); // Get too impress hide orientation later on changing It. System.out.println("*--*--*-- Now hide orientation Is : " + driver.getOrientation()); Thread.sleep(5000); } @AfterTest populace 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. populace void appiumStart() throws IOException, InterruptedException { // Created object of apache CommandLine class. // It volition maiden of all ascendance prompt In background. CommandLine ascendance = novel CommandLine("cmd"); // Add dissimilar arguments In ascendance trouble which requires to maiden of all 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 ascendance trouble arguments to maiden of all appium server. DefaultExecuteResultHandler resultHandler = novel DefaultExecuteResultHandler(); DefaultExecutor executor = novel DefaultExecutor(); executor.setExitValue(1); executor.execute(command, resultHandler); // Wait for fifteen minutes hence that appium server tin maiden of all properly earlier going for examination execution. // Increase this fourth dimension If human face upwards whatever error. Thread.sleep(15000); } // This method Is responsible for stopping appium server. populace static void appiumStop() throws IOException { // Add dissimilar arguments In ascendance trouble which requires to halt appium server. CommandLine ascendance = novel CommandLine("cmd"); command.addArgument("/c"); command.addArgument("taskkill"); command.addArgument("/F"); command.addArgument("/IM"); command.addArgument("node.exe"); // Execute ascendance trouble arguments to halt appium server. DefaultExecuteResultHandler resultHandler = novel DefaultExecuteResultHandler(); DefaultExecutor executor = novel DefaultExecutor(); executor.setExitValue(1); executor.execute(command, resultHandler); } }
Test Decription
- We convey used appiumStart() too appiumStop() methods to maiden of all too halt appium. So appium volition hold out started automatically wehn you lot run your examination too you lot non demand to maiden of all too halt appium manually.
- Another affair nosotros convey Implemented In script Is video recording of PC hide using ATUTestRecorder. You tin alter path to shop recorded video too video file refer every bit per your requirement.
Running Test
When you lot run inwards a higher house software examination using testng, Immediately keep androidscreencast Interface on hand of the screen. Otherwise androidscreencast Interface's hide activities non recorded In video. So when your examination started execution, All the android mobile screen's activities volition display on your PC hide too ATUTestRecorder volition tape your PC screen.
This agency you lot tin tape appium software examination execution video for whatever android app.