Class VisualValidationsBuilder

java.lang.Object
com.shaft.validation.internal.VisualValidationsBuilder
Direct Known Subclasses:
PlaywrightVisualValidationsBuilder

public class VisualValidationsBuilder extends Object
Fluent options builder for the matchesScreenshot() visual-regression assertion.

This builder gathers optional diff-budget and mask options before the visual comparison runs, mirroring Playwright's toHaveScreenshot() options.

  • Constructor Details

    • VisualValidationsBuilder

      public VisualValidationsBuilder(ValidationEnums.ValidationCategory validationCategory, org.openqa.selenium.WebDriver driver, org.openqa.selenium.By locator, boolean pageLevel, StringBuilder reportMessageBuilder)
  • Method Details

    • maxDiffPixels

      public VisualValidationsBuilder maxDiffPixels(int maxDiffPixels)
      Caps the number of differing pixels allowed for the comparison to still pass.
      Parameters:
      maxDiffPixels - maximum allowed differing pixel count
      Returns:
      this builder, to continue chaining options
    • maxDiffPixelRatio

      public VisualValidationsBuilder maxDiffPixelRatio(double 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 builder, to continue chaining options
    • mask

      public VisualValidationsBuilder mask(org.openqa.selenium.By... masks)
      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 builder, to continue chaining options
    • applyOptions

      public VisualValidationsBuilder applyOptions(VisualComparisonOptions options)
      Copies the diff-budget and mask settings from a public VisualComparisonOptions object onto this internal builder. Playwright Locator-based masks are handled separately by the Playwright entry points.
      Parameters:
      options - the caller-supplied options, or null for defaults
      Returns:
      this builder, to continue chaining
    • perform

      public ValidationsExecutor perform()
      Executes the visual-regression comparison (or saves a new baseline on first run / when -Dshaft.updateSnapshots=true is set).
      Returns:
      a ValidationsExecutor object retained for source compatibility