Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Playwright Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-playwright-knowledge-patch)
---
name: playwright-knowledge-patch
description: Playwright
version: "1.65.0"
license: MIT
metadata:
author: Nevaberry
---
# Playwright Knowledge Patch
Load this skill when migrating Playwright code, configuring tests, debugging
browser automation, or working with component stories, MCP, and test agents.
Use the quick reference below for common changes and the topic files for full
guidance and Python, JavaScript, and TypeScript examples.
## Reference index
| Reference | Topics |
| --- | --- |
| [Browser automation](references/browser-automation.md) | Platforms, CDP, lifetimes, locators, actions, cookies, storage, passkeys, networking, diagnostics, ARIA snapshots, screenshots, screencasts |
| [Component testing](references/component-testing.md) | Package removals, migration, stories, galleries, mount fixtures, typed story IDs |
| [MCP server](references/mcp-server.md) | Startup, profiles, bridge, connections, initialization, access controls, tools, capabilities, WebMCP |
| [Test agents](references/test-agents.md) | Agent definitions, seed fixtures, planner, generator, healer, generated artifacts |
| [Test runner and debugging](references/test-runner-and-debugging.md) | Codegen, CLI debugging, assertions, scheduling, retries, traces, HAR, videos, reporters, configuration, runtimes |
## Breaking changes and deprecations
### Removed APIs and selectors
Replace `_react` and `_vue` selectors with supported locators, and replace the
`:light` selector engine suffix with standard CSS selectors.
`page.accessibility` was removed; use an accessibility testing library such as
Axe for page audits.
`BrowserContext` no longer emits the deprecated `"backgroundpage"` event, and
`context.background_pages()` always returns an empty list. Use Manifest V3 for
extensions you load in Chromium; Manifest V2 is no longer supported.
Remove the `handle` keyword from `browser_context.expose_binding()` and
`page.expose_binding()`. To open DevTools automatically, pass
`--auto-open-devtools-for-tabs` as a Chromium launch argument.
`ConsoleMessage` locations expose `line` and `column`; `line_number` and
`column_number` are deprecated. `WebError` exposes a location in the same format.
For video action annotations, replace deprecated `fontSize` with `font-size`
in the CSS declaration string passed through `style.title`.
### Platforms, runtimes and component packages
WebKit support on macOS 13 and 14 was removed. Upgrade macOS to run WebKit,
or retain an older Playwright version on those systems. Debian 11 and Ubuntu
20.04 support was also removed; upgrade Debian 11 hosts and CI images before
moving to the release that drops support.
Use Node.js 22, 24, or 26 because Node.js 20 was dropped from the test matrix.
Playwright's Docker images ship Node.js 26.
`@playwright/experimental-ct-svelte` was removed. The experimental React,
React 17, and Vue component packages will no longer receive updates; migrate
to story-based component tests for continued updates. See the component reference
for exact package names and the migration guide.
### Behavior changes that affect existing tests
Elements inside hidden iframes count as hidden for locator actions,
`locator.isVisible()`, and `expect(locator).toBeVisible()`, including when the
iframe has `visibility: hidden`. An `inert` target or ancestor blocks actions
such as `locator.click()`, `check()`, `tap()`, `fill()`, `clear()`, and
`selectOption()` until the target stops being inert or the action times out.
Accessible names and ARIA snapshots omit unrendered text, including text
unassigned to a slot and text directly inside a closed `<details>`. This can
change `getByRole()` name matches and `toMatchAriaSnapshot()` baselines.
ARIA snapshots also render and compare input placeholders.
Credentials in `proxy` answer proxy authentication challenges only; use
`httpCredentials` for authentication on the destination website. When given a
URL, `browserContext.cookies()` and `apiRequestContext.cookies()` match host-only
cookies on the exact host and use slash-delimited path matching. See the browser
reference for path examples.
Device descriptors forward `screen` to emulated screen dimensions. To opt out,
set `screen: undefined` after spreading the device descriptor.
`compilerOptions.useDefineForClassFields` is honored and defaults to enabled
for `ES2022` and later, and when `target` is omitted. Field initializers can run
before constructor parameter properties are assigned: initialize dependent
fields in the constructor or set `"useDefineForClassFields": false`.
With `--update-snapshots=missing` or `updateSnapshots: 'missing'`, tests that
only create missing snapshots pass. With the setting omitted, `'default'`
writes missing snapshots and fails the affected tests.
A sharded run fails with `No tests found` if zero tests match across all shards,
unless `--pass-with-no-tests` is passed. An empty shard still passes if another
shard has tests. The blob reporter clears its output directory before writing,
including earlier reports with different filenames.
## Locators, actions and cancellation
`page.pickLocator()` highlights elements on hover and resolves to the clicked
element's locator; `page.cancelPickLocator()` cancels selection.
`locator.normalize()` rewrites a locator using preferred strategies such as
roles or test IDs. `get_by_role()` accepts an accessible `description`.
Call `page.frameLocator()` or `frame.frameLocator()` without a selector to
search the frame subtree. The remaining locator resolves within a single frame
and throws if elements match in multiple frames.
`child.within(parent)` resolves the child inside the parent. Relative operations
such as `nth()` and `first()` are evaluated separately for each matched parent.
Use `page.getByRef('e2')` for a reference from `page.ariaSnapshot({ mode: 'ai' })`.
Pass `signal` to cancel most actions, navigations, waits, and web-first
assertions. Normal timeouts still apply; `timeout: 0` disables that timeout.
Python `timeout` parameters accept `datetime.timedelta`.
Pass `scroll="none"` to skip automatic action scrolling; `scroll="auto"` is the
default and scrolls the target into view when needed. `locator.wait_for_function()`
passes the matched element to a JavaScript predicate and waits for a truthy result.
Install `page.clock.install()` before any clock-related calls, including
timers started during page load.
## Browser state and connections
`browserContext.setStorageState()` (`context.set_storage_state()` in Python)
clears cookies, local storage, and IndexedDB across all origins before applying
the supplied state. Partitioned cookies retain `partition_key` through
`BrowserContext.cookies()` and `BrowserContext.add_cookies()`; support and
defaults vary by browser.
`context.credentials` provides a virtual authenticator across Playwright's
browsers. After `install()`, it handles the page's credential creation and
retrieval calls. Include virtual passkeys with `credentials: true` when saving
storage state; use `opfs: true` to include the origin private file system.
Supply the saved state when creating another context to restore those contents.
`browser.bind()` exposes a launched browser to multiple clients and returns an
endpoint for `chromium.connect(endpoint)`. The default transport is a named pipe;
pass `host` and `port` for WebSocket. `browser.unbind()` stops new connections.
For CDP, `is_local=True` enables shared-filesystem optimizations when both ends
run on the same host. `no_defaults=True` preserves default-context download
behavior, focus emulation, and media emulation. `artifacts_dir` selects the
directory for traces and downloads on attach.
## Assertions, snapshots and scheduling
Python `expect.soft()` records failures and continues to later checks; it
requires an up-to-date Playwright pytest integration.
In JavaScript, `expect.soft.poll()` polls a condition and records a failure
without stopping the test on timeout.
ARIA `/children` supports `contain` (the default, ordered subset), `equal`
(exact ordered immediate children), and `deep-equal` (exact ordered child tree).
Set `expect.toMatchAriaSnapshot.children` for the default; a template directive
overrides it. Pass `''` to generate an inline baseline, or use a `.aria.yml`
`name` for a separate file shared across browsers.
Inline updates use `--update-source-method=patch` by default, producing a
unified diff for `git apply`; `3way` inserts conflict markers, and `overwrite`
writes templates directly. New baselines wait for the configured expect timeout;
increase the test's `--timeout` if it expires before capture.
Use a `.webp` snapshot name for lossless screenshot baselines. Configure
`expect.toHaveScreenshot.type` as `'webp'` for unnamed screenshot baselines.
Tests sharing a named `lock` never run concurrently within the run, including
across files, workers, and projects. Tests can hold multiple locks.
`test.describe.configure({ lock: 'user-settings' })` applies a lock to every
test in the enclosing file or group; `-exclusive-` makes a test run alone.
Set `retryStrategy: 'isolated'` to run retries at the end, one at a time in one
worker. The default, `'immediate'`, retries as soon as a worker is free.
Use `--shuffle` to randomize scheduling and its printed seed to reproduce order.
Set `default: false` on a project to omit it from a plain test run. Select it
with `--project=firefox`, or use `--project="*"` to run every project.
## Diagnostics, recording and CLI tools
Retrieve recent events with `page.console_messages()`, `page.page_errors()`,
and `page.requests()`. `page.consoleMessages()` and `page.pageErrors()` accept
`filter`; clear their buffers with `page.clearConsoleMessages()` and
`page.clearPageErrors()`. `request.existingResponse()` checks for an already
arrived response without waiting.
Use `context.tracing.start({ live: true })` for live trace updates. Set trace
mode to `'retain-on-failure-and-retries'` to record every attempt and keep all
traces if any attempt fails, including a passing retry.
`page.screencast.start()` captures an existing page; combine `path` for a WebM
saved on `stop()` with `onFrame` for JPEG buffers during capture. Size bounds
preserve aspect ratio and default to the viewport fitted within 800×800;
an active capture such as tracing can override them. The browser reference
covers overlays, action styling, frame timestamps, frame rate, and codec.
`playwright open` opens a browser without starting the recorder; use
`playwright codegen` to record interactions. For test debugging, run
`npx playwright test --debug=cli` and attach with the printed session name.
The runner reference includes commands for inspecting trace actions and snapshots.
## MCP, component stories and test agents
Run the bundled MCP server with `npx playwright mcp` and browser CLI with
`npx playwright cli`. Use the Playwright MCP Bridge with `--extension` to access
the tabs and state of running Chrome or Edge; it takes precedence over `browser`.
MCP capability groups include `--caps=network`, `--caps=storage`,
`--caps=devtools`, `--caps=testing`, `--caps=vision`, `--caps=pdf`, and
`--caps=config`. Use comma-separated names to enable multiple groups.
The MCP reference covers each group's tools, origin filters, and file access.
Launch Chromium with `--enable-features=WebMCP` to list and call app-registered
tools through `page.webmcp` or `frame.webmcp`. MCP exposes them as
`webmcp_<tool>` by default; `--no-webmcp` disables that exposure.
For component tests, serve a gallery that renders stories by ID. The `mount`
fixture returns a locator scoped to the story root with `update(props)` and
`unmount()`. The generated `Stories` registry can type story IDs.
Generate test-agent definitions with `init-agents` and the client's `--loop`,
then regenerate after upgrading Playwright. Give the planner a seed test that
provides a ready-to-use `page` through project fixtures. Plans go under `specs/`;
the generator checks selectors and assertions in the live app while writing
tests under `tests/`. The healer can skip a test if it concludes functionality
is broken.