Class PlaywrightScreenshotHandler

java.lang.Object
com.norconex.crawler.web.fetch.util.AbstractScreenshotHandler<com.microsoft.playwright.Page>
com.norconex.crawler.web.fetch.impl.playwright.PlaywrightScreenshotHandler
All Implemented Interfaces:
Configurable<ScreenshotHandlerConfig>

public class PlaywrightScreenshotHandler extends AbstractScreenshotHandler<com.microsoft.playwright.Page>

Takes screenshots of pages using a Playwright Page. Either the entire page viewport, or a specific DOM element identified by a CSS selector. Screenshot images can be stored in a document metadata/field or in a local directory.

Unlike the Selenium-based ScreenshotHandler, Playwright captures element screenshots natively without manual image cropping.

Since:
4.0.0
See Also:
  • Constructor Details

    • PlaywrightScreenshotHandler

      public PlaywrightScreenshotHandler()
    • PlaywrightScreenshotHandler

      public PlaywrightScreenshotHandler(CachedStreamFactory streamFactory)
  • Method Details

    • captureScreenshotBytes

      protected byte[] captureScreenshotBytes(com.microsoft.playwright.Page page)
      Captures a screenshot using Playwright's native API. When a CSS selector is configured, only the matching element is captured (no manual image cropping required); otherwise the full viewport is captured.
      Specified by:
      captureScreenshotBytes in class AbstractScreenshotHandler<com.microsoft.playwright.Page>
      Parameters:
      page - the Playwright page to screenshot
      Returns:
      screenshot bytes
    • toString

      public String toString()
      Overrides:
      toString in class AbstractScreenshotHandler<com.microsoft.playwright.Page>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class AbstractScreenshotHandler<com.microsoft.playwright.Page>
    • canEqual

      protected boolean canEqual(Object other)
      Overrides:
      canEqual in class AbstractScreenshotHandler<com.microsoft.playwright.Page>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractScreenshotHandler<com.microsoft.playwright.Page>