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
muslnode 18–226 runs
build_error
glibcnode 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'));
});
});
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.
fixEnsure 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.
fixMove director.assign() to the start of the test suite.
Audit
Dependencies
playwrightrequiredCore dependency: Playright wraps Playwright for browser automation