Class PlaywrightPhotoLens

java.lang.Object
net.serenitybdd.playwright.PlaywrightPhotoLens
All Implemented Interfaces:
net.serenitybdd.core.photography.PhotoLens

public class PlaywrightPhotoLens extends Object implements net.serenitybdd.core.photography.PhotoLens
A PhotoLens implementation for Playwright Page screenshots.

This class implements the Serenity PhotoLens interface to enable Playwright-based screenshot capture integration with Serenity's photography system.

Screenshots are captured as full-page PNG images by default.

  • Constructor Details

    • PlaywrightPhotoLens

      public PlaywrightPhotoLens(com.microsoft.playwright.Page page)
      Creates a new PlaywrightPhotoLens for the given Page.
      Parameters:
      page - the Playwright Page to use for screenshots (may be null)
  • Method Details

    • takeScreenshot

      public byte[] takeScreenshot()
      Takes a screenshot of the current page state.
      Specified by:
      takeScreenshot in interface net.serenitybdd.core.photography.PhotoLens
      Returns:
      the screenshot as a byte array, or empty array if screenshot cannot be taken
    • canTakeScreenshot

      public boolean canTakeScreenshot()
      Checks if a screenshot can be taken.
      Specified by:
      canTakeScreenshot in interface net.serenitybdd.core.photography.PhotoLens
      Returns:
      true if the page is available and not closed, false otherwise
    • getPage

      public com.microsoft.playwright.Page getPage()
      Returns the underlying Playwright Page.
      Returns:
      the Page instance, or null if not set