Class PlaywrightVisualComparisonOptions

java.lang.Object
com.shaft.validation.VisualComparisonOptions
com.shaft.gui.playwright.validation.PlaywrightVisualComparisonOptions

public class PlaywrightVisualComparisonOptions extends VisualComparisonOptions
Playwright variant of VisualComparisonOptions that adds a Playwright Locator-based mask(...) overload, for use with the Playwright engine's assertThat(...).matchesScreenshot(options) assertion.
driver.element().assertThat(locator)
      .matchesScreenshot(PlaywrightVisualComparisonOptions.create()
              .maxDiffPixelRatio(0.01)
              .mask(page.locator("#timestamp")));
  • Constructor Details

    • PlaywrightVisualComparisonOptions

      public PlaywrightVisualComparisonOptions()
  • Method Details

    • create

      public static PlaywrightVisualComparisonOptions create()
      Returns:
      a new, empty Playwright options object to configure and pass to matchesScreenshot(...)
    • maxDiffPixels

      public PlaywrightVisualComparisonOptions maxDiffPixels(int maxDiffPixels)
      Description copied from class: VisualComparisonOptions
      Caps the number of differing pixels allowed for the comparison to still pass.
      Overrides:
      maxDiffPixels in class VisualComparisonOptions
      Parameters:
      maxDiffPixels - maximum allowed differing pixel count
      Returns:
      this options object, to continue chaining
    • maxDiffPixelRatio

      public PlaywrightVisualComparisonOptions maxDiffPixelRatio(double maxDiffPixelRatio)
      Description copied from class: VisualComparisonOptions
      Caps the ratio of differing pixels (0.0-1.0) allowed for the comparison to still pass.
      Overrides:
      maxDiffPixelRatio in class VisualComparisonOptions
      Parameters:
      maxDiffPixelRatio - maximum allowed differing pixel ratio
      Returns:
      this options object, to continue chaining
    • mask

      public PlaywrightVisualComparisonOptions mask(org.openqa.selenium.By... masks)
      Description copied from class: VisualComparisonOptions
      Excludes the region(s) covered by the given locators from the pixel comparison.
      Overrides:
      mask in class VisualComparisonOptions
      Parameters:
      masks - locators of elements whose bounding boxes should be excluded from the diff
      Returns:
      this options object, to continue chaining
    • mask

      public PlaywrightVisualComparisonOptions mask(com.microsoft.playwright.Locator... masks)
      Excludes the region(s) covered by the given Playwright locators from the pixel comparison.
      Parameters:
      masks - Playwright locators of elements whose bounding boxes should be excluded from the diff
      Returns:
      this options object, to continue chaining
    • getPlaywrightMaskLocators

      public List<com.microsoft.playwright.Locator> getPlaywrightMaskLocators()
      Returns:
      the (possibly empty) list of Playwright locators whose regions are excluded from the diff