how to screenshot in appium+serenity

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

  

posted @ 2017-11-03 15:06  startToDo  阅读(221)  评论(0)    收藏  举报