我使用以下脚本拍摄了鸦片测试的屏幕截图。

String path;
     try {
         WebDriver augmentedDriver = new Augmenter().augment(driver);
         File source = ((TakesScreenshot)augmentedDriver).getScreenshotAs(OutputType.FILE);
         path = "/Users/admin/Desktop/newfolder" + source.getName();
              org.apache.commons.io.FileUtils.copyFile(source, new File(path));
          }
           catch(IOException e) {
                path = "Failed to capture screenshot: " + e.getMessage();
            }

我想将它们带到带有时间戳的文件夹中。

但是现在我将它们放置在这样的桌面上
java - 如何更改将屏幕快照获取到名为时间戳的文件夹的路径?-LMLPHP

如何在appium测试期间为文件夹提供路径以保存这些屏幕截图?

最佳答案

尝试使用以下方法创建带有时间戳名称的文件夹:
String.valueOf(new Timestamp(System.currentTimeMillis()))。replace(“:”,“-”)

10-07 19:51
查看更多