Convert Manual Test Cases to Playwright Spec
Reads manual test steps (Action / Expected Result) and produces a Playwright spec with locator suggestions, action method calls (assuming a POM exists), assertions matching expected results, and explicit `// MANUAL:` comments where automation can't replicate human judgment.
When to use it
- Migrating a manual regression suite to Playwright as part of an automation initiative.
- Onboarding manual testers into automation — keep the original cases visible alongside the code.
- Auditing manual coverage to find which cases CAN'T be automated and need to stay manual.
- Bootstrapping E2E test files for a brand-new feature when manual cases were written first.
The prompt
XML-tagged — best for Claude 4.x
<role>
You are a Playwright automation engineer with experience migrating legacy manual suites. You know that not every manual step can or should be automated, and you mark those steps explicitly so they don't get silently lost in translation.
</role>
<context>
The team has manual test cases in classic Action / Expected Result format. They use Playwright with TypeScript and assume a POM file already exists for the page (or will be created). Steps requiring visual judgment, real device sensors, or human interaction get a `// MANUAL:` comment with explanation rather than being auto-automated.
</context>
<task>
Convert the manual test case below into a Playwright TypeScript spec. For each manual step:
1. If automatable: emit Playwright code using `await page.<action>` or a POM method call.
2. If NOT automatable (visual judgment, real-device features, human interaction, time-dependent oracle): emit a `// MANUAL: <reason>` comment instead.
3. Map each Expected Result to an `await expect(...)` assertion or to a MANUAL note.
</task>
<input>
Manual test case (Action / Expected Result):
{test_case}
POM available for page (yes/no, name if yes): {pom_info}
Locators known (paste any data-testid values): {locators}
</input>
<constraints>
- Output is a single `.spec.ts` file.
- Every original manual step appears as either Playwright code or a `// MANUAL:` comment — no step silently skipped.
- Locators are real values from {locators} when provided; otherwise placeholders like `getByRole('button', { name: 'TODO_NAME' })` with a TODO marker.
- No `page.waitForTimeout` — use auto-waiting expects.
- Imports assume `@playwright/test`.
</constraints>
<output_format>
A code block with the TypeScript spec, followed by a "Coverage note" paragraph summarizing: how many steps were automated, how many marked MANUAL, and any locators that need to be filled in.
</output_format>
Before writing, identify which steps require human judgment vs which are mechanically automatable.Example
Common pitfalls
- Model silently automates judgment steps (e.g., 'verify animation looks smooth' becomes `expect(...).toBeVisible()`). Force the MANUAL flag in the prompt.
- Hallucinated locator names appear without TODO marker — review every selector before running.
- Multi-step setup ('Navigate to cart with one item') gets expanded into 10 micro-steps, losing intent. Prefer POM methods over raw clicks for setup.
- MANUAL comments are treated as decorative — make sure your team has a workflow for handling them (separate manual suite, follow-up tickets, etc.).
Tips
- Provide the POM info even if you have to lie — the output is much cleaner when the model uses POM methods than raw Playwright calls.
- Run this in batches by feature, not file-by-file — the model picks up consistent patterns within a feature.
- For dynamic content (timestamps, IDs), add an explicit constraint like 'mask values matching <regex> in screenshots'.
- After conversion, run the generated spec once in headed mode to confirm locators resolve before committing.
FAQ
Don't automate them. Tag with `// MANUAL:` and keep them in a separate manual checklist for releases. Automating perceptual oracles produces flaky tests that erode confidence.
Related prompts
Generate Playwright Page Object Model
Give the model a page description plus a list of UI elements and it returns a complete Page Object Model in TypeScript using Playwright's auto-waiting locators (getByRole / getByTestId), typed action and assertion methods, and a page-level fixture.
Open →Generate Cypress Page Object Model
Returns a Cypress Page Object class using cy.get() with data-cy preference, action methods that chain via `return this`, plus a commands.js file for cross-page utilities and a sample spec consuming the POM.
Open →Refactor Flaky Test to Stable
Takes a flaky test and its failure history, identifies which of the canonical root causes (race, hard sleep, shared state, network dependency, ordering, animation) is responsible, and produces a rewritten test that fixes the specific cause — no blanket retries.
Open →Review Test Code for Anti-Patterns
Reads a test file and returns a categorized list of anti-patterns — hard sleeps, shared mutable state, weak assertions (`toBeTruthy` instead of `toEqual`), missing teardown, mixed setup/assertion concerns — each with line numbers, severity, and a suggested fix.
Open →