Class ImageProcessingActions
java.lang.Object
com.shaft.gui.internal.image.ImageProcessingActions
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic BooleancompareAgainstBaseline(String elementLocatorName, byte[] elementScreenshot, ImageProcessingActions.VisualValidationEngine visualValidationEngine) Compares backend-neutral screenshot bytes against the visual baseline for the supplied locator description.static BooleancompareAgainstBaseline(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By elementLocator, byte[] elementScreenshot, ImageProcessingActions.VisualValidationEngine visualValidationEngine) static voidcompareImageFolders(String referenceFolderPath, String testFolderPath, double threshold) compareScreenshotAgainstBaseline(String baselineKey, byte[] actualScreenshot, List<int[]> maskRects, Integer maxDiffPixels, Double maxDiffPixelRatio) Compares a backend-neutral actual screenshot (e.g. a full-page capture) against its visual-regression baseline using a pixel-level diff.compareScreenshotAgainstBaseline(org.openqa.selenium.By elementLocator, byte[] actualScreenshot, List<int[]> maskRects, Integer maxDiffPixels, Double maxDiffPixelRatio) Compares an element's actual screenshot against its visual-regression baseline using a pixel-level diff.findImageWithinCurrentPage(String referenceImagePath, byte[] currentPageScreenshot) static StringformatElementLocatorToImagePath(String elementLocatorName) Formats a backend-neutral locator description into the stable visual-baseline file-name hash used by SHAFT.static StringformatElementLocatorToImagePath(org.openqa.selenium.By elementLocator) Formats a Selenium locator into the stable visual-baseline file-name hash used by SHAFT.static byte[]getReferenceImage(String elementLocatorName) Reads the existing reference image for a backend-neutral locator, when present.static byte[]getReferenceImage(org.openqa.selenium.By elementLocator) Reads the existing reference image for a Selenium locator, when present.static byte[]getShutterbugDifferencesImage(String elementLocatorName) Reads a generated Shutterbug differences image for a backend-neutral locator, when present.static byte[]getShutterbugDifferencesImage(org.openqa.selenium.By elementLocator) static byte[]highlightElementInScreenshot(byte[] targetScreenshot, org.openqa.selenium.Rectangle elementLocation, Color highlightColor) static voidstatic voidLoads the optional visual processing provider when it is available.
-
Method Details
-
compareImageFolders
-
highlightElementInScreenshot
public static byte[] highlightElementInScreenshot(byte[] targetScreenshot, org.openqa.selenium.Rectangle elementLocation, Color highlightColor) -
findImageWithinCurrentPage
-
formatElementLocatorToImagePath
Formats a Selenium locator into the stable visual-baseline file-name hash used by SHAFT.- Parameters:
elementLocator- locator of the element being compared- Returns:
- stable hashed baseline file name without extension
-
formatElementLocatorToImagePath
Formats a backend-neutral locator description into the stable visual-baseline file-name hash used by SHAFT.- Parameters:
elementLocatorName- stable element locator description- Returns:
- stable hashed baseline file name without extension
-
getReferenceImage
public static byte[] getReferenceImage(org.openqa.selenium.By elementLocator) Reads the existing reference image for a Selenium locator, when present.- Parameters:
elementLocator- locator of the element being compared- Returns:
- encoded reference image bytes, or
nullwhen no baseline exists
-
getReferenceImage
Reads the existing reference image for a backend-neutral locator, when present.- Parameters:
elementLocatorName- stable element locator description- Returns:
- encoded reference image bytes, or
nullwhen no baseline exists
-
getShutterbugDifferencesImage
public static byte[] getShutterbugDifferencesImage(org.openqa.selenium.By elementLocator) -
getShutterbugDifferencesImage
Reads a generated Shutterbug differences image for a backend-neutral locator, when present.- Parameters:
elementLocatorName- stable element locator description- Returns:
- encoded differences image bytes, or an empty byte array when no differences image exists
-
compareAgainstBaseline
public static Boolean compareAgainstBaseline(org.openqa.selenium.WebDriver driver, org.openqa.selenium.By elementLocator, byte[] elementScreenshot, ImageProcessingActions.VisualValidationEngine visualValidationEngine) -
compareAgainstBaseline
public static Boolean compareAgainstBaseline(String elementLocatorName, byte[] elementScreenshot, ImageProcessingActions.VisualValidationEngine visualValidationEngine) Compares backend-neutral screenshot bytes against the visual baseline for the supplied locator description.- Parameters:
elementLocatorName- stable element locator descriptionelementScreenshot- encoded screenshot bytesvisualValidationEngine- requested visual validation engine- Returns:
truewhen the comparison passes or creates a new baseline
-
compareScreenshotAgainstBaseline
public static VisualProcessingProvider.ScreenshotComparisonResult compareScreenshotAgainstBaseline(org.openqa.selenium.By elementLocator, byte[] actualScreenshot, List<int[]> maskRects, Integer maxDiffPixels, Double maxDiffPixelRatio) Compares an element's actual screenshot against its visual-regression baseline using a pixel-level diff. Saves the actual screenshot as the new baseline when none exists yet, or when-Dshaft.updateSnapshots=true.- Parameters:
elementLocator- locator of the element being comparedactualScreenshot- encoded screenshot bytes of the current statemaskRects- pixel-space[x, y, width, height]regions to exclude from comparison, ornullmaxDiffPixels- maximum allowed differing pixel count, ornullto ignore this budgetmaxDiffPixelRatio- maximum allowed differing pixel ratio (0.0-1.0), ornullto ignore this budget- Returns:
- the comparison result
-
compareScreenshotAgainstBaseline
public static VisualProcessingProvider.ScreenshotComparisonResult compareScreenshotAgainstBaseline(String baselineKey, byte[] actualScreenshot, List<int[]> maskRects, Integer maxDiffPixels, Double maxDiffPixelRatio) Compares a backend-neutral actual screenshot (e.g. a full-page capture) against its visual-regression baseline using a pixel-level diff. Saves the actual screenshot as the new baseline when none exists yet, or when-Dshaft.updateSnapshots=true.- Parameters:
baselineKey- stable backend-neutral baseline descriptionactualScreenshot- encoded screenshot bytes of the current statemaskRects- pixel-space[x, y, width, height]regions to exclude from comparison, ornullmaxDiffPixels- maximum allowed differing pixel count, ornullto ignore this budgetmaxDiffPixelRatio- maximum allowed differing pixel ratio (0.0-1.0), ornullto ignore this budget- Returns:
- the comparison result
-
loadOpenCV
public static void loadOpenCV() -
loadOpenCVIfAvailable
public static void loadOpenCVIfAvailable()Loads the optional visual processing provider when it is available. Engine startup uses this method so installations that do not includeshaft-visualremain quiet until a visual operation is requested.
-