Appium Appium 在用 java 实现截图功能

二宝爸爸 · 2014年03月18日 · 最后由 Archer 回复于 2014年03月18日 · 1396 次阅读
public void testScreenshot() throws IOException {
    final String desfilepath = "/Users/zhoutu/Desktop/zyj/aaa.png";
    // make screenshot and get is as base64
    final WebDriver augmentedDriver = new Augmenter().augment(driver);
    ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.BASE64);
    // make screenshot and save it to the local filesystem
    final File srcfile = ((TakesScreenshot) augmentedDriver)
        .getScreenshotAs(OutputType.FILE);
    try {
      FileUtils.copyFile(srcfile, FileUtils.getFile(desfilepath), true);
    } catch (final Exception e) {
      System.out.println(e.toString() + "\n");
    }
  }

直接调用即可,建议图片名称采用时间戳,然后传入进来.这样在你的 html 中即可查看你的图片了.

共收到 1 条回复 时间 点赞

markdown 用起来,这样看代码简直要疯了!

需要 登录 後方可回應,如果你還沒有帳號按這裡 注册