// Matched one comparison but not all, remove all error images +
// HTML files
} else {
- // All comparisons failed, keep the main error image + HTML
- screenshotFailures.add(mainReference.getName());
- referenceToKeep = mainReference;
+ // Ensure we use the correct browser version (e.g. if running IE11
+ // and only an IE 10 reference was available, then mainReference
+ // will be for IE 10, not 11)
+ String originalName = getScreenshotReferenceName(identifier);
+ File exactVersionFile = new File(originalName);
+
+ if (!exactVersionFile.equals(mainReference)) {
+ // Rename png+html to have the correct version
+ File correctPng = getErrorFileFromReference(exactVersionFile);
+ File producedPng = getErrorFileFromReference(mainReference);
+ File correctHtml = htmlFromPng(correctPng);
+ File producedHtml = htmlFromPng(producedPng);
+
+ producedPng.renameTo(correctPng);
+ producedHtml.renameTo(correctHtml);
+ referenceToKeep = exactVersionFile;
+ screenshotFailures.add(exactVersionFile.getName());
+ } else {
+ // All comparisons failed, keep the main error image + HTML
+ screenshotFailures.add(mainReference.getName());
+ referenceToKeep = mainReference;
+ }
}
// Remove all PNG/HTML files we no longer need (failed alternative
File failurePng = getErrorFileFromReference(failedAlternative);
if (failedAlternative != referenceToKeep) {
// Delete png + HTML
- String htmlFileName = failurePng.getName().replace(".png",
- ".html");
- File failureHtml = new File(failurePng.getParentFile(),
- htmlFileName);
+ File failureHtml = htmlFromPng(failurePng);
failurePng.delete();
failureHtml.delete();
}
}
+ /**
+ * Returns a new File which points to a .html file instead of the given .png
+ * file
+ *
+ * @param png
+ * @return
+ */
+ private static File htmlFromPng(File png) {
+ return new File(png.getParentFile(), png.getName().replaceAll(
+ "\\.png$", ".png.html"));
+ }
+
/**
*
* @param referenceFile