java.lang.Object
net.serenitybdd.playwright.PlaywrightPageRegistry
Thread-safe registry for Playwright Page instances.
This class provides ThreadLocal storage for Playwright Page objects, enabling proper isolation in parallel test execution scenarios. Each test thread maintains its own set of registered pages.
Usage:
// Register a page for screenshot capture PlaywrightPageRegistry.registerPage(page); // Get all registered pages for the current thread List<Page> pages = PlaywrightPageRegistry.getRegisteredPages(); // Cleanup at end of test PlaywrightPageRegistry.clear();
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Clears all registered pages for the current thread.static List<com.microsoft.playwright.Page>Returns an unmodifiable list of all registered pages for the current thread.static booleanChecks if there are any registered pages for the current thread.static voidregisterPage(com.microsoft.playwright.Page page) Registers a Playwright Page instance for the current thread.static voidunregisterPage(com.microsoft.playwright.Page page) Unregisters a Playwright Page instance from the current thread.
-
Constructor Details
-
PlaywrightPageRegistry
public PlaywrightPageRegistry()
-
-
Method Details
-
registerPage
public static void registerPage(com.microsoft.playwright.Page page) Registers a Playwright Page instance for the current thread.Once registered, the page will be used for automatic screenshot capture during step execution. Null values and duplicate registrations are ignored.
- Parameters:
page- the Playwright Page to register (may be null)
-
unregisterPage
public static void unregisterPage(com.microsoft.playwright.Page page) Unregisters a Playwright Page instance from the current thread.- Parameters:
page- the Playwright Page to unregister
-
getRegisteredPages
Returns an unmodifiable list of all registered pages for the current thread.- Returns:
- unmodifiable list of registered Page instances
-
clear
public static void clear()Clears all registered pages for the current thread.This should be called in test cleanup to ensure proper resource management.
-
hasRegisteredPages
public static boolean hasRegisteredPages()Checks if there are any registered pages for the current thread.- Returns:
- true if at least one page is registered, false otherwise
-