THE REPLACEQA BLOG
Turn a manual test case into a Playwright test
Turn a manual browser check into a Playwright test with explicit setup, meaningful assertions and a controlled failure that verifies the test.
To turn a manual test case into a Playwright test, first make its starting state and expected outcome explicit. Record or write the actions, add assertions for that outcome, then confirm the test fails when the intended behavior breaks. Automating an ambiguous checklist row simply repeats the ambiguity faster.
This walkthrough converts “check pricing” into one test for a fictional monthly/yearly price selector. It includes a local fixture and an intentional defect, so you can compare the working and broken behavior yourself.
Expand the checklist row
“Check pricing” leaves too much to memory. Which plan, billing interval, currency and state should the tester inspect? Does changing the button's appearance count as a pass, or must the amount change too?
For this fixture, the product contract is deliberately small:
| Part of the manual case | Defined behavior |
|---|---|
| Starting state | Fresh visitor at /pricing; Monthly selected |
| Initial amount | $12 / month |
| Action | Select Yearly |
| Selection outcome | Yearly pressed; Monthly not pressed |
| Amount outcome | $120 / year |
| Data impact | Display change only; no purchase |
These prices are fictional fixture values, not ReplaceQA's prices. In your application, use an independently maintained requirement or controlled test dataset. Do not scrape the current annual price and immediately assert that the same element contains it.
Keep this case focused. Selecting a yearly billing view does not establish that checkout, invoices or payment collection work. Those are separate behaviors with different setup and consequences.
Use recording to draft the interaction
Download the example package, extract it and install dependencies:
npm ci
npx playwright install chromium
npm start
With the fixture server running, open a second terminal in the same directory:
npx playwright codegen http://127.0.0.1:4319/pricing
Select Yearly and use the recorder's assertion controls where useful. Playwright's generator supports recording interactions and visibility, text and value assertions; it is not limited to copying clicks. Its test-generator documentation explains those controls.
Review what you recorded. Remove exploratory actions that are not part of this case, such as repeatedly switching billing intervals while deciding what to test. Keep the transition from the defined initial state to the intended final state.
The finished test below is an authored example, not a claim that an unedited recorder session produced this exact source. A recording is a useful starting point; the manual case remains the authority for what the test must prove.
Stop the standalone fixture server before running the packaged test. Its test configuration starts and stops its own instance and deliberately refuses to reuse an existing server.
Give every required outcome an assertion
The complete test in tests/manual.spec.js is:
import { test, expect } from '@playwright/test';
test('yearly pricing shows the specified annual amount', async ({ page }) => {
await page.goto('/pricing');
await expect(page.getByTestId('price')).toHaveText('$12 / month');
await page.getByRole('button', { name: 'Yearly', exact: true }).click();
await expect(page.getByRole('button', { name: 'Yearly', exact: true })).toHaveAttribute('aria-pressed', 'true');
await expect(page.getByRole('button', { name: 'Monthly', exact: true })).toHaveAttribute('aria-pressed', 'false');
await expect(page.getByTestId('price')).toHaveText('$120 / year');
});
The initial amount assertion establishes the starting display. The two pressed-state assertions verify the selection. The final price assertion verifies the consequence that matters to the visitor.
The fixture uses accessible button names for actions and a dedicated test ID for the price. Your implementation might use a radio group or a select element instead. Choose locators that describe its actual controls; do not retrofit button selectors onto a different interaction model.
Keep the assertions awaited. Playwright's assertion guide explains how its asynchronous web assertions wait for an expected condition. You do not need an arbitrary sleep between clicking Yearly and checking the price.
Run it outside the recording session
Run the finished test with:
npx playwright test tests/manual.spec.js
The packaged configuration starts a clean local application, opens Chromium, executes the case and shuts the application down. This removes any dependence on the browser session you used while recording.
A useful next check is whether someone else can run the same command from the same lockfile and fixture. If they need your browser's cookies, a manually selected option or a piece of undocumented data, the setup is incomplete. Make that prerequisite explicit before putting the case into a release pipeline.
Confirm it catches the broken toggle
The fixture has a defect mode that changes the selected button but leaves the monthly amount on screen. Run it in a Linux/macOS shell:
DEMO_FAULT=toggle npx playwright test tests/manual.spec.js
This command should fail. During local validation with Playwright Test 1.63.0, the healthy fixture passed. The defective fixture reached the Yearly pressed state but failed the final price assertion: the expected $120 / year was still $12 / month.
That result explains why “the click completed” or “Yearly is selected” would be insufficient for this requirement. The test must observe the amount after the action. The archive's evidence.json records both runs.
After inspecting or saving the failure evidence, rerun without DEMO_FAULT to restore the healthy fixture. In a real application, make the defect in a controlled development environment and keep the test unchanged while fixing the product.
Put the test back into the release process
Update the original checklist row with the test's name, the command or pipeline that runs it, its owner and the behavior it covers. Leave the remaining manual checks visible. One automated pricing selector case does not replace the rest of the release checklist.
When pricing intentionally changes, update the agreed expected values and review the resulting test change. If the UI structure changes while the requirement stays the same, adjust the interaction without discarding the amount assertion that caught the defect.
Use the production smoke checklist to place this check among the other release tasks. If you have not yet chosen which tasks to automate, the testing strategy without a QA team provides a starting point.
ReplaceQA's closed beta discovers public journeys and generates Playwright scripts with validation evidence. Request access if you want help finding and preparing those checks; keep the same explicit requirements when reviewing the generated result.