Browser mode
The Browser Mode API is provided by @rstest/browser, designed to let you use a Playwright-style Locator workflow in browser tests.
Exported API
@rstest/browser provides the runtime entry for Browser Mode. Its core responsibility is locating elements and driving interactions.
page is the query entry point, Locator handles chaining and action execution, BrowserPage describes the query APIs supported by page, and setTestIdAttribute configures the test id attribute name.
The following are the APIs currently exported by @rstest/browser:
page-BrowserPagequery entry (queries only)Locator- Core class for chained queries and interactionsBrowserPage- Type definition forpagesetTestIdAttribute- Configure the attribute name used bygetByTestId()
Assertion API
The assertion entry point is expect.element(locator).
When you import @rstest/browser in a Browser Mode test (e.g., import { page } from '@rstest/browser'), expect automatically gains the element capability.
Its responsibility is to perform web-first assertions (with auto-waiting) on a Locator, such as toBeVisible and toHaveText.
The relationship between the two can be understood as: @rstest/browser is responsible for finding and operating on elements, while expect.element is responsible for verifying element state.
expect.element(locator)- Perform auto-waiting assertions on aLocator
Example: query, interaction, and assertion
In this example, page first creates a Locator, the Locator executes fill/click, and finally expect.element(locator) performs a visibility assertion on the result, forming a complete test cycle.