Class VisualComparisonOptions
java.lang.Object
com.shaft.validation.VisualComparisonOptions
- Direct Known Subclasses:
PlaywrightVisualComparisonOptions
Options for the
matchesScreenshot(...) visual-regression assertion, mirroring Playwright's
toHaveScreenshot() options.
Build with create() and the fluent setters, then pass the result to
assertThat(...).matchesScreenshot(options). The comparison runs when the terminal
assertion is called.
driver.element().assertThat(By.id("logo"))
.matchesScreenshot(VisualComparisonOptions.create()
.maxDiffPixelRatio(0.01)
.mask(By.id("timestamp")));
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic VisualComparisonOptionscreate()List<org.openqa.selenium.By> mask(org.openqa.selenium.By... masks) Excludes the region(s) covered by the given locators from the pixel comparison.maxDiffPixelRatio(double maxDiffPixelRatio) Caps the ratio of differing pixels (0.0-1.0) allowed for the comparison to still pass.maxDiffPixels(int maxDiffPixels) Caps the number of differing pixels allowed for the comparison to still pass.
-
Constructor Details
-
VisualComparisonOptions
public VisualComparisonOptions()
-
-
Method Details
-
create
- Returns:
- a new, empty options object to configure and pass to
matchesScreenshot(...)
-
maxDiffPixels
Caps the number of differing pixels allowed for the comparison to still pass.- Parameters:
maxDiffPixels- maximum allowed differing pixel count- Returns:
- this options object, to continue chaining
-
maxDiffPixelRatio
Caps the ratio of differing pixels (0.0-1.0) allowed for the comparison to still pass.- Parameters:
maxDiffPixelRatio- maximum allowed differing pixel ratio- Returns:
- this options object, to continue chaining
-
mask
Excludes the region(s) covered by the given locators from the pixel comparison.- Parameters:
masks- locators of elements whose bounding boxes should be excluded from the diff- Returns:
- this options object, to continue chaining
-
getMaxDiffPixels
- Returns:
- the configured maximum differing pixel count, or
nullif unset
-
getMaxDiffPixelRatio
- Returns:
- the configured maximum differing pixel ratio, or
nullif unset
-
getMaskLocators
- Returns:
- the (possibly empty) list of locators whose regions are excluded from the diff
-