Download Record Appium Test Execution Video For Android App - Software Testing Tutorials graphic type that can be scaled to use with the Silhouette Cameo or Cricut. An SVG's size can be increased or decreased without a loss of quality. All of our downloads include an image, Silhouette file, and SVG file. It should be everything you need for your next project. Our SVG files can be used on adhesive vinyl, heat transfer and t-shirt vinyl, or any other cutting surface
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;
public class 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
public void setUp() throws Exception {
// Start appium server.
appiumStart();
// Get current date and time to provide in recorded video name.
DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH-mm-ss");
Date date = new Date();
// Created object of ATUTestRecorder.
// Provide path to store videos and file name format.
recorder = new ATUTestRecorder("D:\\ScriptVideos\\", "TestVideo-" + dateFormat.format(date), false);
DesiredCapabilities capabilities = new 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 = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
// To start video recording of your PC screen.
recorder.start();
}
@Test
public void performOrientation() throws InterruptedException {
// Get and print current screen orientation.
System.out.println("*--*--*-- Current screen orientation Is : " + driver.getOrientation());
System.out.println("*--*--*-- Changing screen Orientation to LANDSCAPE.");
// Changing screen Orientation to LANDSCAPE.
driver.rotate(org.openqa.selenium.ScreenOrientation.LANDSCAPE);
// Get and print screen orientation after changing It.
System.out.println("*--*--*-- Now screen orientation Is : " + driver.getOrientation());
Thread.sleep(5000);
// Scroll till element which contains "Views" text If It Is not visible on screen.
driver.scrollTo("Views");
// Click on Views.
driver.findElement(By.name("Views")).click();
System.out.println("*--*--*-- Changing screen Orientation to PORTRAIT.");
// Changing screen Orientation to PORTRAIT.
driver.rotate(org.openqa.selenium.ScreenOrientation.PORTRAIT);
// Get and print screen orientation after changing It.
System.out.println("*--*--*-- Now screen orientation Is : " + driver.getOrientation());
Thread.sleep(5000);
}
@AfterTest
public void End() throws IOException, ATUTestRecorderException {
driver.quit();
// Stop appium server when test Is ended.
appiumStop();
// Stop video recording.
recorder.stop();
}
// This method Is responsible for starting appium server.
public void appiumStart() throws IOException, InterruptedException {
// Created object of apache CommandLine class.
// It will start command prompt In background.
CommandLine command = new CommandLine("cmd");
// Add different arguments In command line which requires to start 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 store appium server log file.
command.addArgument("D://appiumLogs.txt");
// Execute command line arguments to start appium server.
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command, resultHandler);
// Wait for 15 minutes so that appium server can start properly before going for test execution.
// Increase this time If face any error.
Thread.sleep(15000);
}
// This method Is responsible for stopping appium server.
public static void appiumStop() throws IOException {
// Add different arguments In command line which requires to stop appium server.
CommandLine command = new CommandLine("cmd");
command.addArgument("/c");
command.addArgument("taskkill");
command.addArgument("/F");
command.addArgument("/IM");
command.addArgument("node.exe");
// Execute command line arguments to stop appium server.
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
executor.execute(command, resultHandler);
}
}
- We have used appiumStart() and appiumStop() methods to start and stop appium. So appium will be started automatically wehn you run your test and you not need to start and stop appium manually.
- Another thing we have Implemented In script Is video recording of PC screen using ATUTestRecorder. You can change path to store recorded video and video file name as per your requirement.
Download Record Appium Test Execution Video For Android App - Software Testing Tutorials All SVG file downloads also come bundled with DXF, PNG, and EPS file formats. All designs come with a small business commercial license. These SVG cut files are great for use with Silhouette Cameo or Cricut and other Machine Tools.