public void takeScreenshot(String command) { BrowserType browser = configuration.getBrowser().getType(); BufferedImage screenshot = null; File imageOutputFile = new File( screenshotsOutputDir, MetamerTestInfo.getAssociatedFilename(method) + "/" + getFileName(command)); if (browser == BrowserType.FIREFOX) { screenshot = selenium.captureEntirePageScreenshot(); File directory = imageOutputFile.getParentFile(); String newHash = calculateHash(screenshot); if (lastImageHash == null || !lastImageHash.equals(newHash)) { try { FileUtils.forceMkdir(directory); calculateHash(screenshot); ImageIO.write(screenshot, "PNG", imageOutputFile); } catch (IOException e) { throw new RuntimeException(e); } lastImageHash = newHash; } } }