Objective: Read a complete automated test end to end — declaration, arrange, act, assert — and state what automation is and is not, so no line of a real test is left as "just syntax."
⏱ ≈2 h practice unit · Code: copy, paste, practise · English edition — Español · العربية · বাংলা in translation
🧽 The practice business: FreshNest Home Cleaning — a fictional local cleaning company (owner: Maya Torres) invented for this course. Every example and exercise uses FreshNest, so you learn on a complete, realistic business without ever touching a real one.
First, the framing from B-01. A test is a list of checks — "the heading says X", "the button is visible" — and each check passes or fails. Automation means a program performs those steps and checks exactly the same way, every time, in seconds: a smoke alarm, not a night watchman — narrow, tireless, exact. What automation is NOT matters just as much: it does not decide what matters and it does not explore. It repeats verdicts on checks humans chose, so an all-green suite means exactly one thing — the checks we wrote still hold. The choosing rule follows: boring + repeated + costly to miss → automate it; new + needs judgment → explore it by hand.
Every automated test carries an ID in its title — in the source suite, [TC-001]; in this course's lab, TC-FN-PRC-001. The ID is the test's permanent name: the same ID lives in the test-case document and in the results, so one case keeps one identity everywhere it appears, and IDs are never renumbered. The declaration test(title, async ({ page }) => { … }) registers the test with Playwright; { page } is a fixture — a fresh browser page the framework hands the test automatically.
Inside, every test has three beats: arrange, act, assert. Arrange builds the Page Object; act does the thing; assert checks the result. The pair async / await keeps those beats honest: loading a page takes real time, await means "wait until this step finishes before the next line", and async marks the function as one allowed to wait. Notice what the test does NOT contain: no selectors, no URLs, no expected text — those live in the Page Object, so when the site changes, one line changes in one file, not in every test.
The original worked code for this unit, verbatim, with its line-by-line explanations. Run it against the course practice project (download on the course page).
test("[TC-001] HomePage loads with its expected title and heading", async ({ page }) => {test(...) declares a test. The title carries the ID. And { page } is the browser page the framework hands you — your window into the DOM from B-02.
const po = new HomePage(page);
await po.goto();
await po.expectLoaded();1) Build the page object. 2) Go to the page. 3) Verify it loaded correctly. That's the entire test — three honest lines.
test("[TC-001] HomePage loads with correct title and heading", async ({ page }) => {
const po = new HomePage(page);
await po.goto();
await po.expectLoaded();
});From the module's full text.
test("[TC-001] HomePage loads with correct title and heading", async ({ page }) => {From the module's full text.
const po = new HomePage(page);From the module's full text.
await po.goto();From the module's full text.
await po.expectLoaded();From the module's full text.
test("[TC-001] HomePage loads with correct title and heading", async ({ page }) => {
const po = new HomePage(page);
await po.goto();
await po.expectLoaded();
});From the module's full text.