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 Summary
ConstructorsConstructorDescriptionPlaywrightPhotoLens(com.microsoft.playwright.Page page) Creates a new PlaywrightPhotoLens for the given Page. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if a screenshot can be taken.com.microsoft.playwright.PagegetPage()Returns the underlying Playwright Page.byte[]Takes a screenshot of the current page state.
-
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:
takeScreenshotin interfacenet.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:
canTakeScreenshotin interfacenet.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
-