Skip to content

Convert Manual Test Cases to Playwright Spec

Test AutomationUpdated 2026-10-21advanced
TL;DR

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: works best with Claude
convert-manual-to-playwright.claude.mdprompt
<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:` comment. `// MANUAL:` is only for steps a human must do, never for a missing locator.- Third-party widgets (payment forms in iframes): automate them in the vendor's test mode with `frameLocator`; only CAPTCHA and real-device steps stay MANUAL.- 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> <approach>Before writing, identify which steps require human judgment vs which are mechanically automatable.</approach>

Example

Input
Manual test case: Verify checkout flow with discount code

| # | Action | Expected Result |
|---|--------|-----------------|
| 1 | Navigate to cart with one item ($100) | Cart page displays item, subtotal $100 |
| 2 | Click "Apply discount code" link | Code input appears with focus on input field |
| 3 | Visually verify the input field animation is smooth (no jank) | Animation appears smooth |
| 4 | Enter code "SAVE20" | Input shows "SAVE20" |
| 5 | Click Apply | Discount of $20 displayed; subtotal updates to $80 |
| 6 | Click "Pay with card" | Stripe payment widget loads |
| 7 | Pay using a real test card ending 4242 | Payment succeeds, redirect to /order/:id |

POM available: yes, CartPage
Known locators: data-testid="discount-link", data-testid="discount-input", data-testid="apply-discount", data-testid="discount-applied", data-testid="subtotal"
Output
```typescript
import { test, expect } from '@playwright/test';
import { CartPage } from './pages/CartPage';

test('checkout with SAVE20 discount applies $20 off subtotal', async ({ page }) => {
  const cart = new CartPage(page);

  // Step 1: Navigate to cart with one item ($100)
  await cart.gotoWithItem({ price: 100 });
  await expect(cart.subtotal).toHaveText('$100.00');

  // Step 2: Click "Apply discount code" link
  await page.getByTestId('discount-link').click();
  await expect(page.getByTestId('discount-input')).toBeFocused();

  // Step 3: Visually verify the input field animation is smooth (no jank)
  // MANUAL: Animation smoothness is a perceptual oracle. Use Playwright trace + a human reviewer, or capture a video for visual regression with frame-diff if you must automate.

  // Step 4: Enter code "SAVE20"
  await page.getByTestId('discount-input').fill('SAVE20');
  await expect(page.getByTestId('discount-input')).toHaveValue('SAVE20');

  // Step 5: Click Apply
  await page.getByTestId('apply-discount').click();
  await expect(page.getByTestId('discount-applied')).toContainText('-$20.00');
  await expect(cart.subtotal).toHaveText('$80.00');

  // Step 6: Click "Pay with card"
  // TODO: confirm the exact button label.
  await page.getByRole('button', { name: 'TODO_NAME_pay_with_card' }).click();
  // TODO: confirm the Stripe iframe title in your integration.
  const stripe = page.frameLocator('iframe[title="Secure payment input frame"]');
  await expect(stripe.getByPlaceholder('1234 1234 1234 1234')).toBeVisible();

  // Step 7: Pay using test card 4242 (Stripe test mode)
  await stripe.getByPlaceholder('1234 1234 1234 1234').fill('4242424242424242');
  await stripe.getByPlaceholder('MM / YY').fill('12 / 34');
  await stripe.getByPlaceholder('CVC').fill('123');
  // TODO: confirm the submit button label.
  await page.getByRole('button', { name: 'TODO_NAME_pay' }).click();
  await expect(page).toHaveURL(/\/order\/[\w-]+$/);
});
```

Coverage note: 6 of 7 steps automated. Step 3 (animation smoothness) is flagged MANUAL: it needs a human eye. Three values need confirmation from the app, each marked `// TODO:`: the "Pay with card" button label, the Stripe iframe title, and the final pay button label. Step 7 only works against Stripe test mode keys; never point it at live payments.

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

  • If no POM exists yet, name the one you plan to create: 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

What about steps requiring real human judgment (UX intuition, visual appeal)?

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.

How should I handle environment setup steps (data prep, user creation)?

Move them out of the test body and into a Playwright fixture or a `beforeEach`. Manual steps like 'create a user with role X' become fixtures that all tests reuse, not inline code.

How should I validate locator guesses the model makes?

Run the test against the app in headed mode and observe failures. Locators that don't resolve give descriptive errors. Better: provide real data-testid values in the prompt input, the model fabricates much less when given concrete inputs.

Should I throw away the manual cases after conversion?

No. Keep the manual cases in test-management as the source of truth for what's covered. The Playwright code is one implementation of those cases. If you delete the manual records, you lose the ability to discuss coverage in non-engineering terms.

Use with these tools