Registry / testing / playright

playright

JSON →
library0.0.22jsnpmunverified

Playright is a user-oriented test wrapper for Playwright, porting Selenide/Selene patterns from the Selenium world. At version 0.0.22, it is an early-stage experimental API with release cadence TBD. Key differentiators: fluent API with 'element', 'elements', 'perform', 'have' helpers; supports multi-context/browser/page tests; ships TypeScript types. Unlike raw Playwright, it provides a higher-level declarative style inspired by Selenide, but is still in very early draft and not production-ready.

npm install playright
INSTALL
IMPORT
SIG · PLAYRIGHT
P
playright
testingjavascriptv0.0.22
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

director
✓ import { director } from 'playright'
✗ const director = require('playright').director
ESM-only; director is a named export that manages browser, context, and page lifecycle
element
✓ import { element } from 'playright'
Named export for locating a single element by CSS selector
elements
✓ import { elements } from 'playright'
Named export for locating multiple elements by CSS selector
goto
✓ import { goto } from 'playright'
Named export to navigate the current page to a URL
perform
✓ import { perform } from 'playright'
Named export containing actions like press, click, etc.
have
✓ import { have } from 'playright'
Named export for assertions such as texts, cssClass, count, etc.
stage
✓ import { stage } from 'playright'
Named export for managing test stages or contexts

Shows basic Playright API: director setup, navigating, typing, chaining actions with perform, and asserting with have on element collections.

import { director, goto, element, elements, perform, have } from 'playright'; describe('TodoMVC', () => { beforeAll(async () => { jest.setTimeout(60 * 1000); director.assign({ launchOptions: { headless: false } }); // true by default }); afterEach(async () => { await director.dispose(); }); it('should complete todo', async () => { await goto('http://todomvc.com/examples/emberjs'); await element('#new-todo').type('a').then(perform.press('Enter')); await element('#new-todo').type('b').then(perform.press('Enter')); await elements('#todo-list li').should(have.texts('a', 'b')); await elements('#todo-list li').first.element('.toggle').click(); await elements('#todo-list li').by(have.cssClass('completed')).should(have.texts('a')); }); });
Debug
Known issues
breakingEarly draft: API is unstable and may change without notice in minor version bumps (0.x).
fix
Pin exact version and expect breaking changes.
affects: >=0.0.0 <1.0.0
gotchadirector.assign must be called before any other API calls (like goto). If not assigned, default settings are used but can lead to unexpected states.
fix
Always call director.assign with desired options at the start of the test or beforeAll.
affects: >=0.0.0
gotchaThe 'element' function does not support chaining on elements other than the first one; to filter use elements().by() or elements().firstBy().
fix
Use elements() with methods like .by(), .first(), .element(index) for collection operations.
affects: >=0.0.0
deprecatedAs of v0.0.22, there is no dedicated warning system; check CHANGELOG for deprecations.
fix
Watch GitHub releases and CHANGELOG.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'page')
Trying to use goto or element without first calling director.assign() or disposing previous context.
fix
Ensure director.assign is called in beforeAll and director.dispose in afterEach/afterAll.
Error: When using director, you must first call director.assign()
director is used before initialization.
fix
Move director.assign() to the start of the test suite.
Upgrade
Version history
0.0.22latest on npm
Audit
Dependencies
playwrightrequiredCore dependency: Playright wraps Playwright for browser automation
Agent activity
7 hits · last 30 days
node
6
Anthropic
1
Resources
playright — npm install playright · libregistry