public void screenshot(final String path_screenshot) throws IOException {
String contextName = this.driver.getContext();
this.driver.context("NATIVE_APP");
File srcFile = this.driver.getScreenshotAs(OutputType.FILE);
this.driver.context(contextName);
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String filename = df.format(new Date());
File targetFile = new File(path_screenshot + filename + ".jpg");
FileUtils.copyFile(srcFile, targetFile);
}
转载于:https://www.cnblogs.com/RainZheng/p/7778251.html
相关资源:JAVA上百实例源码以及开源项目