Appium + java截图方法

    public static void takeScreenShot(AndroidDriver<WebElement> driver)
{
File screenShotFile = driver.getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(screenShotFile, new File("D:\\AutoScreenCapture\\" + getCurrentDateTime()+ ".jpg"));
}
catch (IOException e) {e.printStackTrace();}
}
public static String getCurrentDateTime(){
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd_HHmmss");//设置日期格式
return df.format(new Date());
}

方法引用:

takeScreen.takeScreenShot(driver);

上一篇:单点登录系统---SSO


下一篇:appium for hybrid app 处理webview