public static void takeScreenShot(AppiumDriver<MobileElement> driver, String title)
{
File screenShotFile = driver.getScreenshotAs(OutputType.FILE);
try {
String fieName = "D:\\autoScreenCapture\\" +"-"+getCurrentDateTime()+title+".png";
FileUtils.copyFile(screenShotFile, new File(fieName));
}
catch (IOException e) {e.printStackTrace();}
}
public static String getCurrentDateTime(){
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd=HHmmss");//设置日期格式
return df.format(new Date());
}
注意文件名不能带有一些符号比如冒号