Skip to main content
skill CX Codex

recording-browser-flow-as-test — Claude Code skill

Walks through browser interactions step by step via MCP and outputs a clean Playwright test based on accessibility tree selectors.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add spencerpauly/awesome-cursor-skills --skill recording-browser-flow-as-test -a claude-code
Open on GitHub

What recording-browser-flow-as-test does

The skill turns the browser MCP into a test recorder. Instead of relying on a standalone browser extension, it captures snapshots with browser_snapshot, inspects element roles, and performs atomic interactions like browser_click or browser_fill. Every action is tracked in an internal trace. Then, the agent translates the steps into a test spec, usually placed in tests/recorded/<flow-name>.spec.ts.

Locators target accessible names, labels, and roles rather than brittle CSS paths or coordinate clicks. Raw snapshot element references stay out of the generated file because they belong to an ephemeral session. The workflow requires a running dev server and @playwright/test installed in the project. Flows that hit manual 2FA, captchas, or email confirmation links will fail unless you provide mocks or test bypasses.

What it helps with

  • record browser interactions and emit a Playwright spec file
  • generate accessible locators instead of fragile CSS selectors
  • eliminate coordinate-based clicks from automated test suites
  • verify target URLs and visible text after form submissions

Example prompts for the agent

  • Record the flow: log in, open Settings, toggle dark mode, and save as a Playwright test
  • Step through checkout with test data and generate a spec in tests/recorded

How to install recording-browser-flow-as-test

1Skills CLI (Vercel)

npx skills add spencerpauly/awesome-cursor-skills --skill recording-browser-flow-as-test -a claude-code

2Manually: put the files in place

~/.claude/skills/recording-browser-flow-as-test/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/recording-browser-flow-as-test/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about recording-browser-flow-as-test

How to install recording-browser-flow-as-test in Claude Code?

Run npx skills add spencerpauly/awesome-cursor-skills --skill recording-browser-flow-as-test -a claude-code.

What does recording-browser-flow-as-test do?

It executes steps in the browser using MCP actions, records the interactions, and generates a Playwright test with accessibility-based selectors.

When should you avoid using this skill?

Do not use it for user flows requiring manual two-factor authentication, captchas, or external email verification links.

Source text

SKILL.md · CC0-1.0
---
name: recording-browser-flow-as-test
description: Execute a user flow step-by-step in Cursor's built-in browser while documenting each action, then emit a Playwright test that replays the same flow using stable selectors derived from the accessibility tree.
user-invocable: true
---

# Recording Browser Flow as Playwright Test

Use the **browser** MCP as a **recorder**: every navigation, click, fill, and keypress becomes a row in a script. The agent then translates that trace into a **Playwright** test file in the repo (or a snippet to paste into an existing spec).

This is Cursor-native because it combines `browser_snapshot` (refs + roles + names) with structured actions — not a separate recorder extension.

## Prerequisites

- Target app reachable (e.g. dev server running); use `finding-dev-server-url` if needed.
- Repo has or will have Playwright installed (`@playwright/test`). If not, add it with `adding-e2e-tests` or the project’s standard setup.

## Recording workflow

### 1. Define the flow

One sentence scope, e.g. “Log in, open Settings, toggle dark mode, save.”

### 2. For each step, in order

1. **`browser_snapshot`** — get the accessibility tree and element refs.
2. Choose the **smallest** interaction:
   - `browser_click` with ref from snapshot (not coordinate clicks unless required).
   - `browser_fill` or `browser_type` for inputs.
   - `browser_select_option` for selects.
   - `browser_navigate` for full URL changes.
3. **Log the step** in a structured list the main agent keeps:

   - Step number
   - Action verb (`navigate`, `click`, `fill`, `press`, `select`)
   - **Locator strategy for Playwright** — prefer:
     - `getByRole('button', { name: '...' })`
     - `getByLabel('...')`
     - `getByPlaceholder('...')`
     - `getByTestId('...')` if the app uses test IDs
   - Value (for fills), URL (for navigates)
   - Optional: short assertion (“expect URL to contain `/settings`”)

4. After actions that change the DOM or navigate, take a **new** `browser_snapshot` before the next interaction.

5. If the flow must wait for async content, use `browser_wait_for` or short incremental waits per `cursor-ide-browser` guidance — then snapshot again.

### 3. Add assertions

From the final snapshot and URL, add **at least**:

- `expect(page).toHaveURL(...)` or URL fragment check
- One **visible** outcome: text, role, or test id

### 4. Generate Playwright output

Emit a test file, e.g. `tests/recorded/<flow-name>.spec.ts`, containing:

- `test.describe` and `test('...', async ({ page }) => { ... })`
- Steps as `await page.goto(...)`, `await page.getByRole(...).click()`, etc.
- **No** raw snapshot refs in the final file — they are session-specific.

### 5. Run and harden

```bash
npx playwright test tests/recorded/<flow-name>.spec.ts
```

Fix flakiness: prefer `expect(locator).toBeVisible()` before clicks, use `toPass()` retries for async lists, avoid arbitrary `waitForTimeout` except as last resort.

## Tips

- **Stable selectors**: roles and accessible names beat CSS from devtools. Add `data-testid` in app code if names are ambiguous.
- **Auth**: if the flow needs login, use env vars for test credentials or Playwright `storageState` — never commit secrets.
- **Parallel runs**: ensure test data does not collide with other tests.

## When not to use

- Flows that require manual 2FA, captchas, or email links — stop and ask the user for a test bypass or mock.

© spencerpauly · CC0-1.0 · spencerpauly/awesome-cursor-skills

Similar skills

All skills for Testing and QA →

From the same set60

adding-api-docs This skill writes OpenAPI/Swagger documentation for an API: endpoint schemas, request and response types, and an interactive docs page. CX Codex +1 413installs parallel-test-fixing The skill runs your test suite and assigns each failing test file to a separate subagent for parallel fixes. It helps when multiple test files break simultaneously across a codebase. CX Codex +1 412installs profiling-performance This skill profiles web application CPU performance using browser MCP tools. It captures call stacks and pinpoints slow functions causing interface lag. CX Codex +1 410installs python-tdd-with-uv Runs your agent through red-green-refactor in Python and sets the project up on uv. Useful when tests come before the code. CX Codex +1 409installs verifying-markdown-formatting Walks a Markdown file through a formatting checklist and fixes what it finds: headings, lists, links, code blocks, spacing. Useful before committing a README or docs. CX Codex +1 404installs exporting-to-png Teaches the agent to render code snippets, Mermaid diagrams, terminal logs, and SVG files into PNG images via CLI utilities or headless browsers. CX Codex +1 401installs parallel-ci-triage Splits failed GitHub Actions jobs across parallel subagents, each fixing its own slice. Useful when CI breaks in several places at once. CX Codex +1 403installs screenshotting-changelog Builds a visual changelog for a pull request: captures pages before and after your UI edits and drops the image pairs into the PR body. CX Codex +1 401installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor