Record a test with codegen, then make it yours
Use Playwright's recorder to write a first draft of a test from your clicks, then fix its weak spots: add real checks, clear names and no hard-coded data.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: tracing a drawing, then redrawing it freehand. Thin paper over a picture gives you an outline fast. The trace is not your drawing yet. You redraw it, fix the wobbly lines, and add what the outline left out.
Daily List is a to-do list app. Tom, the tester, wants a test for adding a task. He does not know the Playwright calls yet. He clicks through the page like Lily would, and a recorder writes a line for each click.
What it is: Playwright is a library that drives a real browser. This slice is codegen, the recorder that turns clicks and typing into a test. The code it writes is a , a first draft. The nearest neighbour is a test you type by hand. (integrated development environment) and Cypress can record too, and a recording from any of them still needs a human check.
Why it matters: Codegen shows Tom the real call for a journey he can already click, so he is not guessing method names. A draft with no check still passes when the save is broken. He has to add the proof before he trusts the file.
A trace copies a picture that already exists. A recording copies your moves, and the page may change next week. The test still has to make sense then.
(SYNTHETIC / TRAINING ONLY: Daily List, its test site, and every person named here are made up.)
PLAIN WORDS · 7 in this section
- redrawing
- drawing again
- freehand
- Drawn by hand, with no tracing or ruler.
- redraw
- draw again
- wobbly
- shaky and not steady
- playwright
- a free Microsoft tool that drives a browser for tests
- selenium
- A free tool that drives a web browser for checks.
- cypress
- A free tool that drives a web browser for checks.
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Using a recording as a quick first draft, then redrawing it by hand so it checks something real.
- Record the clicks
- Read the code
- Add a real check
- Run and break it
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| Thin paper over a picture | The recorder watching the page |
| The traced outline | The recorded test |
| Redrawing freehand | Editing the draft by hand |
| Adding what the outline left out | Adding checks, names and clean data |
WHERE THIS PICTURE STOPS
- A trace copies a picture that already exists. A recording copies moves, and the page may change.
- A trace has all the lines of the picture. A recording has no idea which result matters.
- Tracing is done once. A test needs care every time the page changes.
HOOK
Trace it, then redraw it.
REMEMBER IT THIS WAY
A chunk: a long list grouped so it is easier to hold.
After a recording, do three edits: name it, check it, trim it.
| In the trick | What it stands for |
|---|---|
| Name it | gives it a clear name |
| Check it | adds a check at the end |
| Trim it | fix the wobbly lines and add what the outline left out |
TELL A FRIEND
Trace a drawing for a quick outline, then redraw it freehand and fix it.
OFTEN MIXED UP WITH The project layout and the config file. The config lesson explains where settings live. This lesson uses the base address from it to shorten the recorded steps.
Sources & standards — 5 sources
- Market practice
Test generator (Playwright documentation) ↗ — Microsoft · Codegen opens a browser and the Playwright Inspector, records clicks and fills as code, lets you add assertions, and offers a Pick locator button once recording stops; it recommends role, text and test id locators (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Writing tests (Playwright documentation) ↗ — Microsoft (Playwright) · A first test opens a page, checks the title, clicks a link found by role and name, and checks the next heading; expect matchers wait until the condition is met (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Best practices (Playwright documentation) ↗ — Microsoft (Playwright) · Test user-visible behaviour, keep tests isolated, prefer role and text locators over fragile selectors, and use web-first assertions (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. A second search on 2026-10-20 returned this page for its title and matched the described content; the page was still not opened (search excerpt, page not opened).
- Market practice
Installation (Playwright documentation) ↗ — Microsoft (Playwright) · Installation / intro: actual setup prompts, generated config/tests, selected browser projects, reports and version-matched browser installation reviewed 6 November 2026. Current source supports Node 22/24/26 lines; no claim that every platform/scaffold option was executed.
Actual complete Installation/intro article inspected during Phase 1 on 6 November 2026, including setup prompts, generated files, selected projects, reports and browser update/install contract. Source inspection is not a claim that every scaffold command, supported operating system or version was executed. Documentation licence CC BY 4.0 was separately reviewed; version and local-execution limits are in the v45 audit.
- Market practice
Generating tests | Playwright ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.
Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.
PRACTISE AND KEEP
Sources for this topic — 5 sources
- Market practice
Test generator (Playwright documentation) ↗ — Microsoft · Codegen opens a browser and the Playwright Inspector, records clicks and fills as code, lets you add assertions, and offers a Pick locator button once recording stops; it recommends role, text and test id locators (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Writing tests (Playwright documentation) ↗ — Microsoft (Playwright) · A first test opens a page, checks the title, clicks a link found by role and name, and checks the next heading; expect matchers wait until the condition is met (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number; read at the time of writing. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Best practices (Playwright documentation) ↗ — Microsoft (Playwright) · Test user-visible behaviour, keep tests isolated, prefer role and text locators over fragile selectors, and use web-first assertions (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail. A second search on 2026-10-20 returned this page for its title and matched the described content; the page was still not opened (search excerpt, page not opened).
- Market practice
Installation (Playwright documentation) ↗ — Microsoft (Playwright) · Installation / intro: actual setup prompts, generated config/tests, selected browser projects, reports and version-matched browser installation reviewed 6 November 2026. Current source supports Node 22/24/26 lines; no claim that every platform/scaffold option was executed.
Actual complete Installation/intro article inspected during Phase 1 on 6 November 2026, including setup prompts, generated files, selected projects, reports and browser update/install contract. Source inspection is not a claim that every scaffold command, supported operating system or version was executed. Documentation licence CC BY 4.0 was separately reviewed; version and local-execution limits are in the v45 audit.
- Market practice
Generating tests | Playwright ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.
Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.