Package base

Class PlaywrightFactory

java.lang.Object
base.PlaywrightFactory

public class PlaywrightFactory extends Object
The class PlaywrightFactory provides a constructor which starts the playwright server. It has private and public methods to create a playwright page.
Author:
Nayeem John
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor to initialize the test properties and playwright server
  • Method Summary

    Modifier and Type
    Method
    Description
    com.microsoft.playwright.Page
    Method to create a new playwright Page for the browser
    static void
    saveSessionState(com.microsoft.playwright.Page page, String filename)
    Method to save the session state from the BrowserContext in a file provided in 'sessionState' property
    static String
    takeScreenshot(com.microsoft.playwright.Page page)
    Method to take screenshot of the Page It saves the screenshots with file name of ${currentTimeMillis}.png

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PlaywrightFactory

      public PlaywrightFactory(TestProperties testProperties)
      Constructor to initialize the test properties and playwright server
      Parameters:
      testProperties - - TestProperties
  • Method Details

    • createPage

      public com.microsoft.playwright.Page createPage()
      Method to create a new playwright Page for the browser
      Returns:
      Page - Returns playwright Page instance or null if any exception occurs while retrieving BrowserContext
    • saveSessionState

      public static void saveSessionState(com.microsoft.playwright.Page page, String filename)
      Method to save the session state from the BrowserContext in a file provided in 'sessionState' property
      Parameters:
      page - - playwright Page instance
      filename - - String name of the file to store session state
    • takeScreenshot

      public static String takeScreenshot(com.microsoft.playwright.Page page)
      Method to take screenshot of the Page It saves the screenshots with file name of ${currentTimeMillis}.png
      Parameters:
      page - - playwright Page instance
      Returns:
      String - Returns encoded Base64 String of image