npm / @playwright/cli
@playwright/cli
What changed in @playwright/cli 0.0 to 0.180, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
36 breaking9 security86 new APIs and options4 performance18 behavior and defaults11 tooling111 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@playwright/cli 0.18010 changes
New APIs and options 9
Selects a browser for the CLI configuration, including Firefox.
Accepts a configuration file for persistent session configuration.
Configures a persistent CLI session to run headed.
Configures an isolated, ephemeral browser context.
Selects a browser to install, including Firefox.
Selects a session for CLI use with the browser extension.
Supports taking a snapshot with the Playwright browser extension.
Starts on-demand video recording in the CLI.
Stops on-demand video recording in the CLI.
Tooling 1
A Playwright CLI executable is available for running browser workflows from the terminal.
@playwright/cli 0.1255 changes
Breaking changes 29
Node.js 20 or newer is required to use this release.
Attaching to a Playwright browser server requires its full ws:// or wss:// endpoint, including the path; HTTP endpoint discovery is removed.
Relative profile, storage-state, executable and output paths in config files resolve next to the config file; paths supplied through flags or environment variables remain relative to the working directory.
Unknown device names report a clear error instead of silently disabling emulation, and context overrides no longer mutate shared device presets.
Repeated downloads receive ordinal filenames such as report-1.csv and report-2.csv instead of overwriting earlier files.
Clicks, fills and option selection wait for inert subtrees to become interactive; inert elements and content outside modal dialogs remain available in snapshots and role locators.
Profile deletion now targets the exact session, so deleting work does not delete the persistent profile of work-test.
Snapshots treat content outside modal dialogs as hidden.
Snapshots exclude unusable controls, and click/fill actions wait for targets to stop being inert.
Normalizes loopback IP URLs to HTTP and bare external hosts with ports to HTTPS.
Works with Chromium 155 and later.
Adds CSS styling for the target highlight; the highlight is shown only when styled.
Adds CSS styling for action point markers; the marker is shown only when styled.
Headless sessions shut down after one hour without commands, so an unclosed session no longer holds a browser; headed browsers stay open.
The default codegen language is inferred from the environment.
Returns the original screenshot bytes instead of silently downscaling them to model-specific limits.
Commands now exit with a non-zero status when the tool result is an error, allowing scripts and agents to detect failures.
JSON responses now carry a structured page snapshot instead of wrapping formatted text in a string.
Navigation reports the HTTP status for non-2xx responses instead of silently succeeding.
The CLI can be invoked through a locally installed Playwright, without a separate global install.
The MCP command is exposed through a locally installed Playwright, without a separate global install.
Honors the configured action timeout instead of waiting indefinitely.
Screenshots with an explicit filename no longer also embed the image in the response.
Extension mode ignores the browser section of loaded config files; browser and channel are determined only by --browser or PLAYWRIGHT_MCP_BROWSER.
Relative paths from --config files resolve against the config directory, while CLI-flag and environment-variable entries resolve against cwd; load errors are surfaced.
The network command is replaced by numbered request listing and detail commands, with separate commands for extracting request and response parts.
Cookie, storage, route, and request/response part commands emit raw output by default, without a Result wrapper or requiring --raw.
Requires an explicit target; bare attach is no longer allowed.
Connecting via the Playwright MCP Bridge extension moved from open to the dedicated attach command, which can also specify the browser.
Security 9
Blocks navigation and form submission from recorded snapshots; trace-file routes reject frame navigations, and the server checks WebSocket origins.
Replaces configured query and fragment parameter values with
<redacted>in command responses.Header-only handlers no longer skip configured allowed- or blocked-origin filters.
No longer copies credential-bearing context options such as HTTP credentials, proxy credentials, extra headers, and storage-state cookies.
Preapproves Playwright commands only, rather than any npm or npx command.
Adds .playwright-cli/ to .gitignore because traces there can contain credentials.
Host and Origin are validated to harden the extension relay against unauthorized cross-origin connections.
The default Chromium browser now runs sandboxed.
Configured secret values are redacted in captured console log artifacts.
New APIs and options 75
Leaves your existing tab organization alone when connecting.
Labels the extension tab group with the session name and keeps disconnected groups available to select on the next connection.
Sets a color for the extension session tab group.
Closes the extension session's tabs before disconnecting; plain detach still leaves them open.
Set background mode in CLI config so attached agents can control tabs while the browser window stays in the background.
Opt in to resolving locators only against visible matches, avoiding strict-mode failures caused by hidden, cached UI.
Set this environment variable to 1 when attaching with the Chrome extension to keep controlled tabs and the browser window in the background.
Set this CLI config option to false so Chrome extension sessions control tabs without creating a tab group or changing existing groups.
Accepts JavaScript, Python, Java, and C# locators; invalid targets explain accepted forms, including how to pass a bare snapshot ref.
Includes retained console entries from earlier navigations.
Limits matching items returned and reports the total match count.
Includes retained request entries from earlier navigations; request numbers remain stable.
Opens a tab with separate cookies and storage; tabs with the same context name share login state.
When a query produces too many matches,
--filenamesaves them to a file.Set filePaths to "absolute" in the config file to get absolute paths for snapshots, screenshots, console logs, and downloads.
Set PLAYWRIGHT_MCP_FILE_PATHS=absolute to get absolute paths for snapshots, screenshots, console logs, and downloads.
Set PLAYWRIGHT_MCP_WEBMCP=false to stop collecting page-registered tools.
Emulates a color scheme on the fly, letting an agent switch between light and dark during a session.
Emulates the contrast media feature on the fly.
Emulates the forced-colors media feature on the fly.
Emulates media features on the fly.
Emulates the reduced-motion media feature on the fly.
Adds CSS declarations for styling video action titles.
The --cursor option renders an animated mouse cursor that travels to each action point and stays visible between actions.
The --fps option records videos at a chosen frame rate; --fps=60 records smooth 60 fps videos instead of the default 25.
Set webmcp to false in the config file to stop collecting page-registered tools.
Sets an idle timeout for attached browsers; they are only detached when this option is set.
Sets the idle timeout for a headless session; 0 disables the timeout.
Configures the idle timeout for a headless session; 0 disables the timeout.
Calls tools a page registers through the WebMCP API, letting the page do the work instead of driving its UI.
Lists the tools a page registers through the WebMCP API.
Stops recording actions performed manually in the browser and returns them as Playwright code.
The -g flag installs the skill into your home directory instead of the current workspace.
The delay the CLI waits for the page to settle after each action is configurable.
Bounding boxes can be enabled globally through configuration instead of per snapshot.
Searches a page snapshot for text or a regexp and returns matching nodes with surrounding context, avoiding capturing large snapshots in model context.
Targets a specific device for mobile emulation.
Emulates a generic mobile device when opening a page, producing mobile pages with smaller snapshots.
Captures screenshots at the device's full pixel ratio instead of downscaling to CSS pixels.
Caps captured output and evicts it to disk after the response to keep large sessions manageable.
Supports attaching to a running browser server endpoint using a WebSocket URL.
Now accepts a full ConnectOptions object, allowing settings like exposeNetwork and headers to apply to remote connections.
Hides action callouts in the recording.
Draws a callout naming each action and highlighting its target in the recording.
The dashboard can collect, annotate, and submit several screenshots in one session, with a sidebar of frames and per-comment highlight.
Part commands accept --filename to save extracted results to a file; bodies are no longer inlined.
Extracts the request body for a numbered request.
Extracts request headers for a numbered request.
Shows full details for one request identified by its stable index.
Lists requests with stable indexes so individual requests can be inspected using numbered commands.
Extracts the response body for a numbered request.
Extracts response headers for a numbered request.
Adds a command to detach an attach session without closing the underlying browser; attach sessions use the channel name.
Drops files or typed data onto an element from outside the page, supporting file-upload widgets and drag-from-desktop scenarios.
Produces a stable Playwright locator expression for an element ref; --raw can feed locators into test assertions.
Shows a persistent highlight overlay on an element; --style customizes it, and --hide hides one or all overlays.
Wraps every reply as structured JSON for machine parsing.
Surfaces Chrome and Edge instances running with remote debugging so they can be targeted by attach --cdp.
Runs a Playwright snippet from a file instead of the command line.
Provides visual and structural feedback while developing or testing.
Includes each element's bounding box in aria snapshots, enabling coordinate-based tools to use snapshot data.
Use --cdp=chrome or another supported browser channel to connect to your local Chrome or Edge, retaining its existing logins instead of using a sandboxed copy.
The attach command accepts a CDP endpoint URL to connect to an existing browser without launching a new one.
The new global flag strips page status, generated code, and snapshot sections, returning only the result value for piping command output into other tools.
Adds a command for attaching to a running Playwright test for interactive debugging.
Adds URL-pattern filtering for network request output.
Adds an option to include request bodies in network output.
Adds an option to include request headers in network output.
Adds a command to simulate network connectivity loss or restore connectivity for offline scenario testing.
Adds a debugger command for stepping over during an attached test session.
Adds a description option for video chapter markers.
Adds a duration option for video chapter markers.
Video recording commands now support action annotations and chapter markers, enabling richer recordings.
Run a test with this option to enable attaching through playwright-cli for interactive debugging; requires @playwright/test v1.59 or later.
Opens a dashboard with live screencasts of running browser sessions, where developers can take remote control, close sessions, or clean up data.
Performance 4
Recording uses less browser CPU on idle animated pages without changing the frames kept in the trace.
Video recordings now use VP9 while keeping WebM output, producing smaller files with less encoding CPU.
The update check result is cached again, avoiding a network round-trip to the npm registry on every command invocation.
Commands that don't need a snapshot run faster because snapshot capture is skipped when the response discards it.
Behavior and default changes 17
When enabled, locators in run-code apply first(), last() and nth() to visible matches; explicit visibility filters still take precedence.
Unix CLI sessions and the dashboard prefer
$XDG_RUNTIME_DIR/playwrightover the shared temporary directory when usable.Scripts can use timers, fetch, URL, Buffer, crypto, AbortController, TextEncoder, and TextDecoder; require and process remain unavailable.
Page-registered WebMCP tools, descriptions, and input schemas appear at the top of the snapshot, so webmcp-call works without first running webmcp-list.
The Chromium sandbox is disabled by default on Linux for the bundled Chromium build, which lacks the setuid sandbox helper.
Session daemons exit when their control socket is deleted or replaced instead of staying alive with the browser.
The check honors NO_UPDATE_NOTIFIER and CI and runs at most once a day.
The session daemon no longer opens a console window on Windows.
Videos for additional tabs are now saved to the configured output directory.
AI snapshots are less verbose, reducing token cost on commands that return page state.
Payloads are no longer included in snapshot or network output, preventing large data URLs from flooding output.
The CLI prompts you to reinstall when the bundled Playwright skill is newer than the one installed in your workspace.
Supports connecting to Firefox over BiDi.
The extension preflight scans every Profile * subdirectory under the user data directory, rather than only Default.
When static requests are filtered out, the request list now hints that --static will show them.
Prints the path to the installed agent skill so coding agents can discover it.
Defaults browserToken to 'chrome' when none is specified, avoiding undefined in userDataDir paths.
Tooling 10
The hint printed after attach now shows -s instead of --s.
Negative positional arguments, such as mousewheel scroll-up deltas, are no longer parsed as flags.
Starts recording actions performed manually in the browser and returns them as Playwright code.
The error message now points to the missing executable when a browser isn't installed.
Downloads are now labeled explicitly in command responses.
Code can now be generated in Python, Java, and C# in addition to JavaScript.
The extension-not-found error now mentions this escape hatch when the extension browser can't be located.
The command now accepts multiple files instead of rejecting a second file.
The CLI notifies you on startup when a newer @playwright/cli is available on npm.
The extension formerly named Playwright MCP Bridge has been renamed, and the CLI warns when it is missing from the target profile.
Fixes and other changes 111
Chromium service workers honor the configured timezone from their first statement, keeping date handling consistent with pages.
A busy existing tab no longer blocks attachment indefinitely; pages that cannot initialize within 10 seconds become available later when they respond.
On Linux ARM64, installs Google's ARM64 Debian package instead of rejecting the architecture.
Running without code or --filename reports a clear input error instead of an internal TypeError.
Embedded comboboxes include their selected option's name in accessible names even when aria-selected uses a mixed-case value such as True.
Connections use the WebSocket path recorded by Chrome instead of failing with a 404.
Browser discovery and attachment on Linux now respect this config directory.
Explicit HTTP URLs and HTTP route mocks stay on HTTP instead of being unexpectedly upgraded or failing in Chromium, Chrome and Edge.
Pending operations on an iframe whose document has not loaded fail when its page closes instead of waiting indefinitely.
Invalid arguments and startup failures return a readable error, or an isError/error object in JSON mode, and exit with code 1 instead of exposing an unhandled rejection.
Label locators and accessible names now recognize labels associated with custom form controls.
Losing the last controlled tab produces an actionable error instead of an undefined-property exception, with guidance for possible debugger detachment by another extension's frame.
Attaching to an existing headless browser preserves its font settings and page layout.
Console source line numbers are now one-based and match editors and DevTools.
Validation errors and recovery hints use runnable CLI command names rather than MCP tool names and avoid doubled Error prefixes.
Evaluation results such as BigInts, circular objects, regular expressions and special numeric values are represented without serialization errors or loss of values; JSON-compatible results keep their format.
Missing Linux dependencies are reported across browsers in one pass, including package names for Vulkan and Graphene.
On Windows, the command correctly reports the daemons it stopped instead of saying none were found.
Full-page screenshots now capture standalone SVG documents instead of timing out.
Snapshots preserve identifying names on dialogs, landmarks, tables and column headers when their heading or caption also appears below them.
In new headless Chrome and Edge, video recording captures the whole viewport without losing the bottom of the page to browser-toolbar sizing.
Commands such as eval and click no longer hang during post-action waits on CSP-sandboxed pages or pages with paused clocks.
Exceptions in page or context listeners registered with run-code appear in console output instead of terminating the session.
Ambiguous matches in slotted web components produce a useful strict-mode error instead of a TypeError when the CSS fallback path is not unique.
Quotes YAML-special text so it remains a string when snapshot output is parsed or reused.
Handles discarded or crashed tabs without wedging commands and closes those tabs while preserving live ones.
Discovers nested frames correctly when attaching to an already-loaded page.
Lets Chrome shut down normally instead of force-killing the browser, preventing temporary app-clone folders from accumulating on macOS.
Deletes only the cookie matching the specified name, domain, and path, leaving same-named cookies elsewhere intact.
Matches the specified domain and its subdomains, not unrelated names; matching ignores case and a leading dot.
Matches the specified path and paths beneath it, not sibling paths.
On pages without a host, asks for a cookie domain instead of returning an internal assertion error.
Surfaces navigation dialogs immediately so they can be handled instead of hanging until timeout.
Accepts Windows source locations such as
C:\tests\example.spec.ts:42.Authenticated proxy URLs retain their credentials instead of failing proxy authentication.
Mocked responses retain supplied headers, including CORS and cache headers.
Request-header replacement and removal work regardless of header-name casing.
Asynchronous route callback errors return their original message without duplicated errors or an extra
Error:prefix.Shows a loaded iframe's content and element refs even when its HTML contains fallback text.
Honors npm registry, scoped registry, proxy, and authentication settings when checking for updates.
Does not open a terminal window that steals focus during background recording on Windows.
The session no longer crashes if the browser closes during a download.
Reports a dialog opened during page load instead of timing out.
Accepts
--no-shellinstead of failing with an unknown-option error.Quotes accessible names that look like regular expressions.
No longer runs a tool in a stale tab or frame.
Matching clear-* commands reset media feature emulation.
route ignores header lines that have no name.
Secrets shorter than 4 characters no longer rewrite the whole output with <secret> markers.
state-save bypasses service workers on the storage state page, avoiding site scripts and failures when they redirect.
A failed upload keeps the file chooser open so the upload can be retried.
When the extension does not connect, attach fails after 30 seconds with a hint instead of hanging indefinitely.
The CLI debugger works for tests that create multiple browser contexts and for every test in a worker.
Explicitly named output files in nested directories no longer fail with ENOENT.
Video chapters and screencast overlays remain visible above open dialogs and popovers.
Drops the cached browser backend after close with a shared browser context, preventing subsequent commands from failing.
The chromiumSandbox setting from the config file is no longer clobbered.
Long workspace paths no longer truncate the daemon socket path and leave sessions stuck with EADDRINUSE.
Orphaned browser preferences entries are no longer treated as an installed extension.
These commands no longer hang when state contains IndexedDB and a page on that origin is open.
Tracing can be restarted after a failed tracing-stop instead of permanently producing broken archives.
The option is now honored in extension mode.
The command now launches the Chrome profile that has the extension installed.
The relay reconnects after the browser extension disconnects.
Special characters in user input are escaped correctly in generated code.
Dialogs dismissed by hand in headed mode no longer leave the session stuck in a modal state.
Connections pass noDefaults so they no longer override existing browser defaults.
The v0.1.17 fix for crashes on privileged pages such as chrome:// was reverted; the crash originates in the browser process itself.
Malformed JSON configuration now produces a clear error instead of being silently parsed as INI.
Attaching over CDP no longer applies unwanted default context options.
Navigating to privileged pages such as chrome://extensions/ no longer crashes the browser session.
Screenshots taken immediately after opening a page wait for page initialization, avoiding a race.
Route patterns containing literal glob characters now match reliably.
Resuming a paused session now settles reliably by waiting for the next pause or context closure.
Stopping tracing when it is not running no longer errors.
Failed network requests are no longer duplicated in output.
A failed session-log write no longer crashes the session.
The legacy flag works again.
Uses waitUntil commit so back and forward navigation resolves more reliably.
Fully stops the dashboard when invoked with --kill.
Accepts a single modifier value such as Shift without requiring a list.
Accepts a single modifier value such as Shift without requiring a list.
Uses a writable cache directory instead of the browsers path, avoiding permission errors on read-only browser installs.
The session environment variable is no longer passed as the daemon endpoint, fixing spurious endpoint resolution.
Custom headers are sent again when connecting to a remote endpoint.
Long session names are trimmed to fit the Unix socket path limit, preventing daemon socket failures.
Invalid tool arguments now produce a readable error instead of failing silently.
Traces are now saved when the CLI attaches to an existing CDP browser.
Creates the traces directory before live .stacks writes, preventing a crash when the directory does not exist.
Reports a missing ffmpeg distinctly from a missing browser when video recording fails.
Browser-scoped commands such as cookie-list and state-save now work when attached via the Chrome extension.
Target resolution no longer misclassifies locators containing e followed by digits.
The current tab is reopened automatically when its renderer crashes.
The next tool call transparently reconnects after a remote browser disconnects mid-session.
When a headed browser is launched with viewport: null, annotate now falls back to window.innerWidth/innerHeight instead of producing an empty annotated screenshot.
Unhandled async callback errors are reported on the next tool response instead of tearing down the MCP transport.
The daemon exits when the browser extension cannot connect, preventing orphaned daemons.
Disables the CDP timeout for extension connections so long-running extension attaches do not time out.
Printed links prefix bare filenames with ./ so they open reliably in terminals and editors.
Displays “(no browsers)” when the list is empty without --all.
Restores closing tabs through the extension in protocol v2.
Closes browsers when the server shuts down, avoiding lingering browser processes.
An explicit CLI proxy now takes precedence over the config-file proxy.
Shows a readable error when attempting tab creation in extension protocol v1 instead of a cryptic failure.
Long CLI or agent sessions no longer leave orphaned Chrome processes that need to be killed manually.
Matches the current cliDaemon.js process so kill-all actually terminates running daemons.
Resolves element refs correctly so snapshots taken after navigation no longer fail to look up references.
The current workspace group is shown first and expanded when running outside a workspace.
The list command no longer crashes when workspaceDir is undefined, allowing it to run outside a workspace.
Providing a URL now navigates the newly opened tab to that URL instead of leaving it blank.
Fixes tracing start/stop behavior.
@playwright/cli 0.010 changes
Breaking changes 7
Browser profiles are now in-memory by default, so every session starts clean with no leftover state.
Closes all browsers.
Forcefully kills all browser processes.
Lists all sessions.
Use
-s=as the shorter session flag.The
--sessionflag has been replaced with-s=.Sessions no longer have a stopped state; they are either running or gone.
New APIs and options 2
Use this option to opt into a persistent profile.
Use this option to specify a custom profile directory.
Behavior and default changes 1
Each workspace gets its own daemon process, preventing cross-project interference and enabling direct daemon startup for faster, more reliable operation.