public String writeScreenshot(BufferedImage image, String url, String urlSubPath, int windowWidth, int yPosition, String step) throws IOException { final String screenshotPath = getScreenshotPath(url, urlSubPath, windowWidth, yPosition, step); writeScreenshot(screenshotPath, image); return screenshotPath; }
public List<String> getFilenamesForStep(String path, String url, String step) throws IOException { final String matcherPattern = "glob:**" + generateScreenshotFileNamePrefix(url, path) + "*_*_" + step + ".png"; Path screenshotDirectory = getScreenshotDirectory(); return getFileNamesMatchingPattern(screenshotDirectory, matcherPattern); }
private String buildRelativePathFromReportDir(String imageFileName) { return imageFileName != null ? fileService.getRelativePathFromReportDirToScreenshotsDir() + imageFileName : null; }
private void createOrClearDirectoryBelowWorkingDir(String workingDirectory, String subDirectory) throws IOException { try { final String subDirectoryPath = workingDirectory + "/" + subDirectory; createDirIfNotExists(subDirectoryPath); clearDirectory(subDirectoryPath); } catch (IOException e) { throw new IOException("Could not create or open " + subDirectory + " directory.", e); } }
public static void deleteDirectory(String path) throws IOException { deleteDirectory(Paths.get(path)); }
public BufferedImage readScreenshot(String fileName) throws IOException { return ImageIO.read(new File(getScreenshotPath(fileName))); }
public void writeComparisonReportAsJson(Report report) throws FileNotFoundException { final String reportJson = gson.toJson(report); fileService.writeJsonReport(reportJson); } }
public static void deleteDirectory(Path path) throws IOException { clearDirectory(path.toString()); Files.deleteIfExists(path); }
public String getRelativePathFromReportDirToScreenshotsDir() { Path screenshotDirectory = getScreenshotDirectory().toAbsolutePath(); Path reportDirectory = getReportDirectory().toAbsolutePath(); Path relative = reportDirectory.relativize(screenshotDirectory); return relative.toString().equals("") ? "" : relative.toString() + "/"; }
public void createWorkingDirectoryIfNotExists() throws IOException { try { createDirIfNotExists(runStepConfig.getWorkingDirectory()); } catch (IOException e) { throw new IOException("Could not create or open working directory.", e); } }
public void writeReport(Report report) throws FileNotFoundException { fileService.writeHtmlReport(renderReport("report", report.getFlatResultList())); }
@VisibleForTesting String getScreenshotPath(String url, String urlSubPath, int width, int yPosition, String step) { return runStepConfig.getWorkingDirectory() + (runStepConfig.getWorkingDirectory().endsWith("/") ? "" : "/") + runStepConfig.getScreenshotsDirectory() + (runStepConfig.getScreenshotsDirectory().endsWith("/") ? "" : "/") + generateScreenshotFileName(url, urlSubPath, width, yPosition, step); }
public void createOrClearScreenshotsDirectory() throws IOException { createOrClearDirectoryBelowWorkingDir(runStepConfig.getWorkingDirectory(), runStepConfig.getScreenshotsDirectory()); }
@VisibleForTesting String generateScreenshotFileName(String url, String urlSubPath, int width, int yPosition, String type) { String fileName = generateScreenshotFileNamePrefix(url, urlSubPath) + String.format("%04d", width) + DIVIDER + String.format("%05d", yPosition) + DIVIDER + type; fileName = fileName + PNG_EXTENSION; return fileName; }
@After public void cleanUp() throws IOException { FileUtils.deleteDirectory(tempJLineupDirectory); }
public void writeRunStepMetadata(Step step, String metadata) throws FileNotFoundException { try (PrintStream out = new PrintStream(new FileOutputStream(getScreenshotPath("metadata_" + step + ".json")))) { out.print(metadata); } } }
public void writeComparisonReportAsJson(Report report) throws FileNotFoundException { final String reportJson = gson.toJson(report.getFlatResultList()); fileService.writeJsonReport(reportJson); } }
public void createOrClearReportDirectory() throws IOException { createOrClearDirectoryBelowWorkingDir(runStepConfig.getWorkingDirectory(), runStepConfig.getReportDirectory()); }
@After public void cleanup() throws IOException { FileUtils.deleteDirectory(tempDirectory); }
@Test public void shouldGenerateFullPathToPngFile() { final String fullFileNameWithPath = testee.getScreenshotPath("testurl", "/", 1001, 2002, "step"); assertThat(fullFileNameWithPath, is(writeScreenshotTestPath + "/screenshots/testurl_root_bbf1812_1001_02002_step.png")); }