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);