@serenity-js/web gives Screenplay actors a consistent way to interact with and query web interfaces without coupling tasks to a particular browser integration tool. It turns low-level actions into reusable, domain-friendly automation that can remain portable across Playwright, WebdriverIO, and Selenium WebDriver. section 15.1.3 section 15.2.5
Use the module to express:
- Interactions such as Navigate.to(url), Click.on(element), Scroll.to(element), and Enter.theValue(value).into(input). section 15.2.5
- Questions such as Text.of(element), Value.of(input), and CssClasses.of(element) for reading interface state. section 15.2.5
- PageElement and PageElements queries that identify controls through basic locators or composable conditions. section 15.2.6
Compose a registration task
A registration task can navigate to the home page and click the Register button: `Task.where('#actor locates the registration form', Navigate.to('/'), Click.on(Form.buttonCalled('Register')))`. The task describes intent while the Web interactions perform the browser-level work. section 15.1.3
import { actorCalled, configure, Cast } from '@serenity-js/core'
import { BrowseTheWebWithPlaywright } from '@serenity-js/playwright'
import * as playwright from 'playwright'
const browser: playwright.Browser = await playwright.chromium.launch() #1
configure({
actors: Cast.whereEveryoneCan(
BrowseTheWebWithPlaywright.using(browser) #2
)
})
actorCalled(‘William’).attemptsTo(
Click.on(PageElement.located(By.css(‘.selector’)), #3
)
Shows how a tool-specific BrowseTheWeb ability supplies the Playwright implementation while the test continues using shared Web APIs. section 15.2.7
