Claude
Skills
Sign in
Back

playwright-interactive-sandbox

Included with Lifetime
$97 forever

Persistent browser interaction through a normal Node.js Playwright script for fast iterative web UI debugging.

Design

What this skill does


## Core Workflow

1. Write a brief QA inventory before testing:
    - Build the inventory from three sources: the user's requested requirements, the user-visible features or behaviors you actually implemented, and the claims you expect to make in the final response.
    - Anything that appears in any of those three sources must map to at least one QA check before signoff.
    - List the user-visible claims you intend to sign off on.
    - List every meaningful user-facing control, mode switch, or implemented interactive behavior.
    - List the state changes or view changes each control or implemented behavior can cause.
    - Use this as the shared coverage list for both functional QA and visual QA.
    - For each claim or control-state pair, note the intended functional check, the specific state where the visual check must happen, and the evidence you expect to capture.
    - If a requirement is visually central but subjective, convert it into an observable QA check instead of leaving it implicit.
    - Add at least 2 exploratory or off-happy-path scenarios that could expose fragile behavior.
2. Start or confirm any required dev server in a persistent TTY session.
3. Write a dedicated Playwright verification script for the changed flow.
4. Run the desktop script first, then add a mobile script if the change affects mobile layouts or touch behavior.
5. After each code change, rerun the verification script from a clean Node.js process.
6. Run functional QA with normal user input.
7. Run a separate visual QA pass.
8. Verify viewport fit and capture the screenshots needed to support your claims.
9. Save screenshot artifacts from the successful run.

## Desktop Verification Script

Set `TARGET_URL` to the app you are debugging. Use port `4444` and prefer `127.0.0.1` over `localhost`.

In this sandbox, Playwright browsers are preinstalled under `/ms-playwright` and `PLAYWRIGHT_BROWSERS_PATH` may already be set to that location. Do not assume the default cache path `~/.cache/ms-playwright`.

In this Debian sandbox, use headless mode for Playwright. Do not spend attempts trying headed mode unless the environment explicitly provides an X server.

In this Debian sandbox, use headless mode for Playwright. Do not spend attempts trying headed mode unless the environment explicitly provides an X server.

In this Debian sandbox, use headless mode for Playwright. Do not spend attempts trying headed mode unless the environment explicitly provides an X server.

```javascript
import { chromium } from 'playwright';

const TARGET_URL = 'http://127.0.0.1:4444';
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({
	viewport: { width: 1600, height: 900 }
});
const page = await context.newPage();

try {
	await page.goto(TARGET_URL, { waitUntil: 'domcontentloaded' });
	console.log('Loaded:', await page.title());

	// Add the task-specific interactions and assertions here.

	await page.screenshot({ path: 'playwright-desktop.png', type: 'png' });
} finally {
	await context.close().catch(() => {});
	await browser.close().catch(() => {});
}
```

Use this pattern for the main changed flow. Keep the script focused on the exact behavior you need to verify.

If you want to confirm the Playwright browser path and installed browser payload, you can run:

```bash
echo "$PLAYWRIGHT_BROWSERS_PATH"
ls -al /ms-playwright
```

Example check run:

```bash
node /tmp/playwright-verify-desktop.mjs
```

## Mobile Verification Script

Use a separate mobile script when the task affects responsive layout or touch behavior.

```javascript
import { chromium } from 'playwright';

const TARGET_URL = 'http://127.0.0.1:4444';
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({
	viewport: { width: 390, height: 844 },
	isMobile: true,
	hasTouch: true
});
const page = await context.newPage();

try {
	await page.goto(TARGET_URL, { waitUntil: 'domcontentloaded' });
	console.log('Loaded mobile:', await page.title());

	// Add the task-specific interactions and assertions here.

	await page.screenshot({ path: 'playwright-mobile.png', type: 'png' });
} finally {
	await context.close().catch(() => {});
	await browser.close().catch(() => {});
}
```

## Iteration Model

- Use one standalone Node.js script per verification pass.
- After code changes, rerun the verification script from a clean process instead of trying to preserve state across runs.
- Keep each script narrow: one changed flow, its main assertions, and its screenshot artifacts.
- If desktop and mobile both matter, run separate scripts or separate invocations rather than one large stateful script.

## Checklists

### Session Loop

- Write and run the Node.js Playwright verification script for the current validation run.
- Launch the target web app from the current workspace.
- Make the code change.
- Reload or restart using the correct path for that change.
- Update the shared QA inventory if exploration reveals an additional control, state, or visible claim.
- Re-run functional QA.
- Re-run visual QA.
- Capture final artifacts only after the current state is the one you are evaluating.

### Reload Decision

- Renderer-only change: reload the existing page.
- New uncertainty about whether the current script still matches the changed behavior: rerun a clean script instead of guessing.

### Functional QA

- Use real user controls for signoff: keyboard, mouse, click, touch, or equivalent Playwright input APIs.
- Verify at least one end-to-end critical flow.
- Confirm the visible result of that flow, not just internal state.
- For realtime or animation-heavy apps, verify behavior under actual interaction timing.
- Work through the shared QA inventory rather than ad hoc spot checks.
- Cover every obvious visible control at least once before signoff, not only the main happy path.
- For reversible controls or stateful toggles in the inventory, test the full cycle: initial state, changed state, and return to the initial state.
- After the scripted checks pass, do a short exploratory pass using normal input for 30-90 seconds instead of following only the intended path.
- If the exploratory pass reveals a new state, control, or claim, add it to the shared QA inventory and cover it before signoff.
- `page.evaluate(...)` may inspect or stage state, but it does not count as signoff input.

### Visual QA

- Treat visual QA as separate from functional QA.
- Use the same shared QA inventory defined before testing and updated during QA; do not start visual coverage from a different implicit list.
- Restate the user-visible claims and verify each one explicitly; do not assume a functional pass proves a visual claim.
- A user-visible claim is not signed off until it has been inspected in the specific state where it is meant to be perceived.
- Inspect the initial viewport before scrolling.
- Confirm that the initial view visibly supports the interface's primary claims; if a core promised element is not clearly perceptible there, treat that as a bug.
- Inspect all required visible regions, not just the main interaction surface.
- Inspect the states and modes already enumerated in the shared QA inventory, including at least one meaningful post-interaction state when the task is interactive.
- If motion or transitions are part of the experience, inspect at least one in-transition state in addition to the settled endpoints.
- If labels, overlays, annotations, guides, or highlights are meant to track changing content, verify that relationship after the relevant state change.
- For dynamic or interaction-dependent visuals, inspect long enough to judge stability, layering, and readability; do not rely on a single screenshot for signoff.
- For interfaces that can become denser after loading or interaction, inspect the densest realistic state you can reach during QA, not only the empty, loading, or collapsed state.
- If the product has a defined minimum supported viewport or wind

Related in Design