LESSON VIEW
LAB-1 · AUTOMATION PRACTICE LAB · PRACTICAL QA

Your First Test, Line by Line

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.

⚡ Key Points

  • Automation repeats human-chosen checks exactly; it never decides what matters.
  • The choosing rule: boring + repeated + costly to miss → automate; new + needs judgment → explore by hand.
  • A test's title carries its TC-ID — one case, one identity, in document, script, and results.
  • Every test reads arrange → act → assert; a beat is never missing, only hiding.
  • Tests hold no selectors, URLs, or expected text — the Page Object holds those, so change lands in one file.

📖 Read

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.

💻 Code for this unit — copy, paste, practise

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).

B-03 · Example 1 — Your first automated test, line by line

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.

B-03 · Example 2 — Your first automated test, line by line

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.

B-03 · Example 3 — Your first automated test, line by line

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.

B-03 · Example 4 — Your first automated test, line by line

test("[TC-001] HomePage loads with correct title and heading", async ({ page }) => {

From the module's full text.

B-03 · Example 5 — Your first automated test, line by line

const po = new HomePage(page);

From the module's full text.

B-03 · Example 6 — Your first automated test, line by line

await po.goto();

From the module's full text.

B-03 · Example 7 — Your first automated test, line by line

await po.expectLoaded();

From the module's full text.

B-01 · Example 1 — What automation is (and is not)

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.