npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

playwright-codegen-pro

v1.0.6

Published

AI-powered Playwright codegen with network capture, data redaction, and MCP integration

Readme

playwright-codegen-pro

A fork of Playwright that supercharges the codegen recorder with AI-ready output — network capture, data redaction, structured prompt export, and MCP integration.

Record your browser session and get a structured prompt that any AI tool (Claude Code, Cursor, ChatGPT) can use to generate a complete, production-ready Playwright test file.

Install

npm install -g playwright-codegen-pro
playwright-codegen-pro install chromium

Usage

playwright-codegen-pro codegen https://myapp.com

AI features are always on. The recorder will:

  • Capture all API calls triggered by your actions (classified as direct/pageLoad/noise)
  • Capture request payloads and response bodies
  • Redact passwords, tokens, and credit card numbers automatically
  • Write a live session file (.playwright-session.md) updated every 250ms
  • Take a screenshot after every recorded action — saved under .playwright-session-screenshots/ and referenced inline in the prompt
  • Record a full session video (1280×720 WebM) — finalized as .playwright-session.webm when the recorder window closes

Files Created During a Session

| File / Directory | When | Purpose | |---|---|---| | .playwright-session.md | Updated live (250ms throttle) | Structured prompt with actions, API calls, screenshot paths | | .playwright-session-screenshots/NNN-{action}.png | After each action commit | Visual context for vision-capable AI | | .playwright-session.webm | After recorder closes | Full session video for vision models | | .playwright-prompt.md | When you click "Generate Test" | Snapshot copy of the prompt |

Workflow 1 — Click "Generate Test"

Interact with your app, then click Generate Test in the recorder toolbar. The structured prompt is copied to your clipboard. Paste it into Claude, Cursor, or ChatGPT.

Workflow 2 — AI reads the session via MCP

Configure the MCP server once (see below), then while codegen is running just tell your AI:

"There's a codegen session running. Read the session and write a test for it."

The AI calls recorder_get_session, reads the live .playwright-session.md, and generates the test — no copy/paste needed.

Workflow 3 — Agent drives the browser via MCP (live recording)

No human recorder needed. Configure the MCP server (see below) and tell your AI:

"Use the playwright-codegen-pro MCP to log in and create a project, then write a test for it."

The agent drives the browser live through the MCP browser tools (browser_navigate, browser_click, browser_type, …), reading each step's snapshot to decide the next move. Recording is always-on: every action the agent fires is captured automatically into:

  • .playwright-session.md — the live prompt (actions + classified API calls + redacted payloads)
  • tests/mcp-session.spec.ts — a runnable draft test that grows with each action

When the agent is done it calls recorder_get_session and turns its own session into a polished final test — no writing a script and iterating run-fail-fix. The exploration is the recording.

Back-to-back flows. To record several independent flows in one MCP session, call recorder_reset between them so each becomes its own clean test instead of piling into one. Pass a name to control the file:

"Test the login flow, then recorder_reset named checkout and test the checkout flow."

recorder_reset({ name: "login" }) writes that flow's draft to tests/login.spec.ts; the next recorder_reset({ name: "checkout" }) starts tests/checkout.spec.ts. The previous flow's file is left in place.

MCP Setup

The MCP server registers itself as playwright-codegen-pro (not playwright), so it sits alongside the official Playwright MCP without clashing — and your AI tool can tell them apart. On connect it sends instructions describing the recorder, so the assistant knows about recorder_get_session and how to turn a recording into a test without you explaining it.

Use a distinct key (playwright-codegen-pro) in your config. Reusing the playwright key collides with the official Playwright MCP and is what makes AI tools think the server is "fake" or fall back to the wrong one.

Claude Code

One-liner (recommended):

claude mcp add playwright-codegen-pro -- npx playwright-codegen-pro mcp

Or edit ~/.claude/settings.json manually:

{
  "mcpServers": {
    "playwright-codegen-pro": {
      "command": "npx",
      "args": ["playwright-codegen-pro", "mcp"]
    }
  }
}

Cursor (~/.cursor/mcp.json or .cursor/mcp.json)

{
  "mcpServers": {
    "playwright-codegen-pro": {
      "command": "npx",
      "args": ["playwright-codegen-pro", "mcp"]
    }
  }
}

VS Code (.vscode/mcp.json or user settings)

{
  "servers": {
    "playwright-codegen-pro": {
      "type": "stdio",
      "command": "npx",
      "args": ["playwright-codegen-pro", "mcp"]
    }
  }
}

After adding it, restart/reload your AI tool and confirm the recorder_get_session tool is listed. If the assistant claims the server doesn't exist, it almost always means the config wasn't picked up (wrong file, not reloaded) — not that the package is missing.

What the prompt includes

  • Every recorded action (click, fill, navigate) with timing
  • API calls linked to each action — method, URL, request payload, response body
  • Sensitive values redacted ([redacted] for passwords and tokens)
  • Playwright best practices baked in (no waitForTimeout, use getByRole, wrap clicks with waitForResponse)
  • Data cleanup instructions when POST 201 creates test data

Example output

## Visual Context
Per-action screenshots: 3 file(s) under .playwright-session-screenshots/ — referenced inline below. Read them as visual context for each step.
Full session video: .playwright-session.webm (finalized when the recorder window is closed).

## Recorded Session
### Page: https://myapp.com/login
- click: Sign In button at t=1200ms
  Screenshot: .playwright-session-screenshots/003-click.png
  API calls (direct):
    - POST /api/auth/login (payload: {"email":"[email protected]","password":"[redacted]"}) -> 200
      (body: {"token":"[redacted]","user":{"email":"[email protected]"}})
    - GET /api/dashboard -> 200 (body: {"items":[...]})

MCP Tools

| Tool | Description | |------|-------------| | recorder_get_session | Read the current or last recorded session | | recorder_reset | Start a fresh recording (optionally named) — for back-to-back flows, each its own test | | browser_navigate | Navigate to a URL | | browser_click | Click an element | | browser_snapshot | Get the accessibility tree | | + 30 more | Full Playwright browser automation via MCP |

Based on

Playwright 1.59.0-next — all standard Playwright APIs and test runner features work as normal.


Playwright Documentation | API reference

Playwright is a framework for Web Testing and Automation. It allows testing Chromium1, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable, and fast.

| | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | | Chromium1 146.0.7680.31 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | WebKit 26.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | Firefox 148.0.2 | :white_check_mark: | :white_check_mark: | :white_check_mark: |

Headless execution is supported for all browsers on all platforms. Check out system requirements for details.

Looking for Playwright for Python, .NET, or Java?

1 Playwright uses Chrome for Testing by default.

Installation

Playwright has its own test runner for end-to-end tests, we call it Playwright Test.

Using init command

The easiest way to get started with Playwright Test is to run the init command.

# Run from your project's root directory
npm init playwright@latest
# Or create a new project
npm init playwright@latest new-project

This will create a configuration file, optionally add examples, a GitHub Action workflow and a first test example.spec.ts. You can now jump directly to writing assertions section.

Manually

Add dependency and install browsers.

npm i -D @playwright/test
# install supported browsers
npx playwright install

You can optionally install only selected browsers, see install browsers for more details. Or you can install no browsers at all and use existing browser channels.

Capabilities

Resilient • No flaky tests

Auto-wait. Playwright waits for elements to be actionable prior to performing actions. It also has a rich set of introspection events. The combination of the two eliminates the need for artificial timeouts - a primary cause of flaky tests.

Web-first assertions. Playwright assertions are created specifically for the dynamic web. Checks are automatically retried until the necessary conditions are met.

Tracing. Configure test retry strategy, capture execution trace, videos and screenshots to eliminate flakes.

No trade-offs • No limits

Browsers run web content belonging to different origins in different processes. Playwright is aligned with the architecture of the modern browsers and runs tests out-of-process. This makes Playwright free of the typical in-process test runner limitations.

Multiple everything. Test scenarios that span multiple tabs, multiple origins and multiple users. Create scenarios with different contexts for different users and run them against your server, all in one test.

Trusted events. Hover elements, interact with dynamic controls and produce trusted events. Playwright uses real browser input pipeline indistinguishable from the real user.

Test frames, pierce Shadow DOM. Playwright selectors pierce shadow DOM and allow entering frames seamlessly.

Full isolation • Fast execution

Browser contexts. Playwright creates a browser context for each test. Browser context is equivalent to a brand new browser profile. This delivers full test isolation with zero overhead. Creating a new browser context only takes a handful of milliseconds.

Log in once. Save the authentication state of the context and reuse it in all the tests. This bypasses repetitive log-in operations in each test, yet delivers full isolation of independent tests.

Powerful Tooling

Codegen. Generate tests by recording your actions. Save them into any language.

Playwright inspector. Inspect page, generate selectors, step through the test execution, see click points and explore execution logs.

Trace Viewer. Capture all the information to investigate the test failure. Playwright trace contains test execution screencast, live DOM snapshots, action explorer, test source and many more.

Looking for Playwright for TypeScript, JavaScript, Python, .NET, or Java?

Examples

To learn how to run these Playwright Test examples, check out our getting started docs.

Page screenshot

This code snippet navigates to Playwright homepage and saves a screenshot.

import { test } from '@playwright/test';

test('Page Screenshot', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  await page.screenshot({ path: `example.png` });
});

Mobile and geolocation

This snippet emulates Mobile Safari on a device at given geolocation, navigates to maps.google.com, performs the action and takes a screenshot.

import { test, devices } from '@playwright/test';

test.use({
  ...devices['iPhone 13 Pro'],
  locale: 'en-US',
  geolocation: { longitude: 12.492507, latitude: 41.889938 },
  permissions: ['geolocation'],
})

test('Mobile and geolocation', async ({ page }) => {
  await page.goto('https://maps.google.com');
  await page.getByText('Your location').click();
  await page.waitForRequest(/.*preview\/pwa/);
  await page.screenshot({ path: 'colosseum-iphone.png' });
});

Evaluate in browser context

This code snippet navigates to example.com, and executes a script in the page context.

import { test } from '@playwright/test';

test('Evaluate in browser context', async ({ page }) => {
  await page.goto('https://www.example.com/');
  const dimensions = await page.evaluate(() => {
    return {
      width: document.documentElement.clientWidth,
      height: document.documentElement.clientHeight,
      deviceScaleFactor: window.devicePixelRatio
    }
  });
  console.log(dimensions);
});

Intercept network requests

This code snippet sets up request routing for a page to log all network requests.

import { test } from '@playwright/test';

test('Intercept network requests', async ({ page }) => {
  // Log and continue all network requests
  await page.route('**', route => {
    console.log(route.request().url());
    route.continue();
  });
  await page.goto('http://todomvc.com');
});

Resources