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-nevaberry-plugins)
---
name: playwright-knowledge-patch
description: Playwright
version: "1.65.0"
license: MIT
metadata:
author: Nevaberry
---
# Playwright Knowledge Patch
Load this skill for Playwright API migrations, browser automation, test runner
configuration, debugging, MCP, and test agents. The references contain the full
guidance and examples; use the quick reference below for common changes.
## Reference index
| Reference | Topics |
| --- | --- |
| [Browser Automation](references/browser-automation.md) | Removed APIs, browser support, Codegen, CDP, state, credentials, locators, networking, clock, diagnostics, ARIA capture, screencasts, HAR |
| [Test Runner and Debugging](references/test-runner-and-debugging.md) | Runtime compatibility, scheduling, retries, assertions, baselines, component stories, traces, videos, reporters |
| [Playwright MCP Server](references/mcp-server.md) | Launch, connections, profiles, initialization, access controls, capability groups, output, WebMCP |
| [Built-in Test Agents](references/test-agents.md) | Definition generation, seed tests, planner, generator, healer, artifact locations |
## Breaking changes and deprecations
- Playwright no longer supports Chromium extensions using Manifest V2; use
Manifest V3 for extensions loaded in Chromium.
- `BrowserContext` no longer emits `"backgroundpage"`, and
`context.background_pages()` always returns an empty list.
- `page.accessibility` was removed. Use an accessibility testing library such as
Axe for page audits.
- Replace `_react` and `_vue` selectors with supported locators, and replace the
`:light` selector engine suffix with standard CSS selectors.
- The DevTools launch option was removed. Pass `--auto-open-devtools-for-tabs`
as a Chromium launch argument to open DevTools automatically.
- Remove `handle` from `browser_context.expose_binding()` and
`page.expose_binding()` calls.
- `ConsoleMessage` locations expose `line` and `column`; `line_number` and
`column_number` are deprecated. `WebError` exposes a location in the same format.
- For video action titles, set `font-size` in `style.title` to replace the
deprecated `fontSize` option.
- `@playwright/experimental-ct-svelte` is no longer available. The experimental
React, React 17, and Vue component packages will no longer receive updates;
migrate those packages to story-based component tests for continued updates.
- WebKit support on macOS 13 and 14 was removed. Upgrade macOS or keep using an
older Playwright version on those systems. Debian 11 and Ubuntu 20.04 support
was also removed; see the browser reference for release-specific guidance.
- Use Node.js 22, 24, or 26 because Node.js 20 was dropped from the test matrix.
Playwright's Docker images now ship Node.js 26.
## Changed behavior to account for
- 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.
- `proxy` credentials answer proxy authentication challenges only. Use
`httpCredentials` for authentication on the destination website.
- With a URL, `browserContext.cookies()` and `apiRequestContext.cookies()` match
host-only cookies on the exact host and use slash-delimited path matching.
- `--update-snapshots=missing` or `updateSnapshots: 'missing'` lets tests that
only create missing snapshots pass. The omitted setting uses `'default'`,
writes missing snapshots, and fails the affected tests.
- Device descriptors forward `screen`. To opt out, set `screen: undefined`
after spreading the device descriptor.
- Playwright honors `compilerOptions.useDefineForClassFields`, enabled by
default 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`.
- The blob reporter clears its output directory before writing, including
earlier reports with different filenames.
## Browser state and credentials
`BrowserContext.cookies()` returns `partition_key` for partitioned cookies,
and `BrowserContext.add_cookies()` accepts it when restoring them. Cookie
partitioning support and defaults vary by browser.
`browserContext.setStorageState()` (`context.set_storage_state()` in Python)
clears cookies, local storage, and IndexedDB across all origins before applying
the supplied state. `page.local_storage` and `page.session_storage` expose the
current origin's storage directly.
`context.credentials` provides a virtual authenticator across Playwright's
browsers. After `install()`, it handles the page's `navigator.credentials.create()`
and `navigator.credentials.get()` calls. Save passkeys with
`context.storageState({ credentials: true })`; supply the saved state when creating
another context. `signCount` is preserved when virtual credentials are saved and
restored through storage state.
Pass `opfs: true` to `context.storageState()` to include the origin private file
system, and supply the returned state as `storageState` to restore those files.
## Locators, actions, and clock control
- `await page.pickLocator()` resolves to the clicked element's locator;
`page.cancelPickLocator()` cancels selection. `await locator.normalize()`
rewrites a locator using preferred strategies such as roles or test IDs.
- `page.frameLocator()` or `frame.frameLocator()` without a selector searches
the frame subtree. The rest of the locator resolves within a single frame
and throws if elements match in multiple frames.
- `child.within(parent)` scopes the child inside the parent. Relative operations
such as `nth()` and `first()` are evaluated separately for each matched parent.
- `scroll="none"` skips automatic action scrolling; `scroll="auto"` is the
default and scrolls the target into view when needed.
- Pass `signal` to cancel most actions, navigations, waits, and web-first
assertions. The normal timeout still applies; `timeout: 0` disables it.
- All Playwright `timeout` parameters accept `datetime.timedelta`, including
navigation, actions, and assertions.
- Install the clock before any clock-related calls, including timers started
during page load. It also controls `requestIdleCallback()`,
`cancelIdleCallback()`, and `Event.timeStamp`.
```ts
await page.clock.install();
await page.goto('http://localhost:3333');
```
## Network and connection controls
In Chromium, Service Worker requests are reported on the browser context and
can be intercepted with `context.route()`. Set
`PLAYWRIGHT_DISABLE_SERVICE_WORKER_NETWORK` to opt out. In Python's async API,
`page.expect_request()` and `page.expect_response()` await async predicates.
For `connect_over_cdp()`, `is_local=True` enables shared-filesystem optimizations
when Playwright and the CDP server share a host. `no_defaults=True` leaves the
attached default context's download behavior, focus emulation, and media
emulation settings in place. `artifacts_dir` selects the traces and downloads
directory on attach.
`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, or use `browser.unbind()` to stop
accepting new connections.
## Test scheduling, runtime, and reporters
- Tests sharing a named `lock` never run concurrently within the run, even across
files, workers, and projects. A test can hold multiple locks. Apply group locks
through `test.describe()` or `test.describe.configure({ lock: 'user-settings' })`.
The built-in `-exclusive-` lock makes a test run alone; other tests can still
run in parallel with each other.
- Set `retryStrategy: 'isolated'` to run retries at the end, one at a time in a
single worker. The default, `'immediate'`, retries as soon as a worker is free.
- `default: false` omits a project from a plain `npx playwright test` run. Select
it with `--project`; `npx playwright test --project="*"` runs every project.
- `npx playwright test --shuffle` randomizes scheduling. Reuse the printed seed
to reproduce the order, for example `npx playwright test --shuffle 271828182`.
- 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 when another
shard has tests.
- `bunx --bun playwright test` runs under Bun. Bun runs lack custom ESM loaders,
ignore `--tsconfig` and JSX options in `tsconfig.json`, skip UI watch reruns and
import tracking for `--only-changed`, and omit test console output from traces
and UI mode.
- The `failures` reporter prints failures and successful retries as they happen,
then a summary. `onlyFailures: true` on HTML, JSON, or JUnit keeps unexpected
outcomes, flaky tests, and interrupted tests.
## Assertions, ARIA, and screenshot baselines
Python's `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 failure without stopping
the test when it times out.
ARIA `/children` accepts `contain` (default, ordered subset), `equal` (exact
ordered immediate children), and `deep-equal` (exact ordered child tree).
`expect.toMatchAriaSnapshot.children` sets the default, with template-level
overrides. Pass `''` to generate an inline baseline; capture waits for the
configured expect timeout, so increase the test's `--timeout` if it expires first.
Inline snapshot updates use `--update-source-method=patch` by default, producing
a unified diff for `git apply`. `3way` inserts merge conflict markers;
`overwrite` writes new templates directly. Use a `.aria.yml` `name` for a file
baseline shared across browsers.
For screenshot assertions, a `.webp` snapshot name stores lossless WebP.
Set `expect.toHaveScreenshot.type` to `'webp'` for unnamed baselines.
`page.screenshot()` and `locator.screenshot()` infer WebP from `.webp` or accept
`type="webp"`; quality `100` is lossless and lower values are lossy.
## Diagnostics, traces, and video
`page.console_messages()`, `page.page_errors()`, and `page.requests()` retrieve
recent diagnostics. `page.consoleMessages()` and `page.pageErrors()` accept
`filter`; `page.clearConsoleMessages()` and `page.clearPageErrors()` reset the
respective buffers. `request.existingResponse()` looks up an arrived response
without waiting.
`page.screencast.start()` captures an existing page. Combine `path` to save WebM
on `stop()` with `onFrame` for JPEG buffers. `size` bounds preserve aspect ratio;
the default fits the viewport within 800×800, but an active capture such as
tracing can override those bounds. Set `fps` for frame rate; Firefox and WebKit
capture up to 25 frames per second, and recordings use VP9.
`use: { trace: 'retain-on-failure-and-retries' }` records every attempt and keeps
all traces if any attempt fails, including a passing retry. Trace `snapshots`
can use `dom`, `aria`, and `screen` switches for per-action capture. With `aria`
and `screen` enabled, **Display Aria** shows the snapshot beside the action
screenshot and highlights nodes on hover.
## MCP and test agents
Run the bundled server with `npx playwright mcp` and browser CLI with
`npx playwright cli`. MCP's persistent profile is keyed by browser channel and
the client's workspace root. Install Playwright MCP Bridge and pass `--extension`
to use tabs and state from running Chrome or Edge; it takes precedence over
the `browser` configuration.
Enable capability groups with comma-separated names: `--caps=network` for
network simulation, `--caps=storage` for state management, `--caps=devtools` for
recording and debugger controls, `--caps=testing` for assertions and locator
generation, `--caps=vision` for coordinate input, and `--caps=pdf` for PDF output.
`browser_network_requests` is a core request-inspection tool.
MCP origin filters use semicolon-separated lists, block entries take precedence,
and filters apply to direct requests only. HTTP `--allowed-hosts` uses a
comma-separated list and defaults to the bind host. File tools default to
workspace roots, or the working directory when roots are absent; `file://`
navigation is blocked by default.
Run `npx playwright init-agents --loop=opencode` for that agent client and
regenerate definitions after upgrading Playwright. Give the planner a seed test
such as `tests/seed.spec.ts` providing `page` through project fixtures. The planner
runs the seed with its setup, dependencies, fixtures, and hooks and writes plans
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
the functionality is broken.