public class OpenChrom {
AndroidDriver<WebElement> driver;
/**
* @author Young
* @throws IOException
*/
public void startRecord() throws IOException {
Runtime rt = Runtime.getRuntime();
// this code for record the screen of your device
rt.exec("cmd.exe /C adb shell screenrecord /sdcard/runCase.mp4");
}
@BeforeClass(alwaysRun = true)
public void setUp() throws Exception {
// set up appium
/**
* This Method create for take screenshot
*
* @author Young
* @param drivername
* @param filename
*/
public static void snapshot(TakesScreenshot drivername, String filename) {
// this method will take screen shot ,require two parameters ,one is
// driver name, another is file name
String currentPath = System.getProperty("user.dir"); // get current work
// folder
File scrFile = drivername.getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy
// somewhere
try {
System.out.println("save snapshot path is:" + currentPath + "/"
+ filename);
FileUtils
.copyFile(scrFile, new File(currentPath + "\\" + filename));
} catch (IOException e) {
System.out.println("Can't save screenshot");
e.printStackTrace();
} finally {
System.out.println("screen shot finished, it's in " + currentPath
+ " folder");
}
}