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.Page
Method to create a new playwrightPage
for the browserstatic void
saveSessionState
(com.microsoft.playwright.Page page, String filename) Method to save the session state from theBrowserContext
in a file provided in 'sessionState' propertystatic String
takeScreenshot
(com.microsoft.playwright.Page page) Method to take screenshot of thePage
It 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 playwrightPage
for the browser- Returns:
- Page - Returns playwright
Page
instance or null if any exception occurs while retrievingBrowserContext
-
saveSessionState
Method to save the session state from theBrowserContext
in a file provided in 'sessionState' property- Parameters:
page
- - playwrightPage
instancefilename
- -String
name of the file to store session state
-
takeScreenshot
Method to take screenshot of thePage
It saves the screenshots with file name of ${currentTimeMillis}.png- Parameters:
page
- - playwrightPage
instance- Returns:
- String - Returns encoded
Base64
String of image
-