BrowseTheWebWithPlaywright
Hierarchy
- BrowseTheWeb<playwright.Locator>
- BrowseTheWebWithPlaywright
Implements
- Discardable
Index
Constructors
Methods
Constructors
constructor
Parameters
session: BrowsingSession<Page<Locator>>
Returns BrowseTheWebWithPlaywright
Methods
staticusing
Parameters
browser: Browser
optionaloptions: PlaywrightOptions
Returns BrowseTheWebWithPlaywright
staticusingPage
Parameters
page: Page
optionaloptions: PlaywrightOptions
Returns BrowseTheWebWithPlaywright
discard
Automatically closes any open Pages when the SceneFinishes
Learn more
Returns Promise<void>
currentPage
Returns a Page representing the currently active browser tab.
Returns Promise<Page<Locator>>
allPages
Returns an array of pages representing all the browser tabs available in the current BrowsingSession.
Returns Promise<Page<Locator>[]>
browserCapabilities
Returns basic meta-data about the browser associated with this ability.
Returns Promise<BrowserCapabilities>
This implementation of the ability to BrowseTheWeb enables the Actor to interact with web front-ends using Playwright.
Using Playwright to
BrowseTheWeb
In the example below, we configure the ability to BrowseTheWebWithPlaywright with a Playwright
Browser
so that Serenity/JS actors can create a newBrowserContext
and instantiate Playwrightpage
s as and when needed.This configuration allows Serenity/JS to control the process of launching and shutting down browser instances and is useful when your test runner, e.g. Cucumber.js, doesn’t offer this functionality.
Using
BrowseTheWeb
with an existing Playwrightpage
Test runners like Playwright Test manage Playwright browsers for you and offer a
page
instance you can inject into the ability to BrowseTheWebWithPlaywright.Note that Serenity/JS Playwright Test module automatically configures all your actors with an ability to BrowseTheWebWithPlaywright, so you don’t need to do it by hand unless you want to override the default configuration.
The example below demonstrates how to use the BrowseTheWebWithPlaywright.usingPage API and override the default Cast of actors.
Learn more