Package base
Class PlaywrightFactory
java.lang.Object
base.PlaywrightFactory
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
ConstructorsConstructorDescriptionPlaywrightFactory(TestProperties testProperties) Constructor to initialize the test properties and playwright server -
Method Summary
Modifier and TypeMethodDescriptioncom.microsoft.playwright.PageMethod to create a new playwrightPagefor the browserstatic voidsaveSessionState(com.microsoft.playwright.Page page, String filename) Method to save the session state from theBrowserContextin a file provided in 'sessionState' propertystatic StringtakeScreenshot(com.microsoft.playwright.Page page) Method to take screenshot of thePageIt saves the screenshots with file name of ${currentTimeMillis}.png
-
Constructor Details
-
PlaywrightFactory
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 playwrightPagefor the browser- Returns:
- Page - Returns playwright
Pageinstance or null if any exception occurs while retrievingBrowserContext
-
saveSessionState
Method to save the session state from theBrowserContextin a file provided in 'sessionState' property- Parameters:
page- - playwrightPageinstancefilename- -Stringname of the file to store session state
-
takeScreenshot
Method to take screenshot of thePageIt saves the screenshots with file name of ${currentTimeMillis}.png- Parameters:
page- - playwrightPageinstance- Returns:
- String - Returns encoded
Base64String of image
-