6. Your first automated script
Test Automation · 48 pages source format
Ship the loop: open → act → assert → see it fail → see it pass. Clean structure comes after the dopamine of green. Pick one stack for this chapter only.
What you'll learn
- Install a runner
- Write one happy path
- Read a failure calmly
Pick a stack for this week
Playwright or Cypress are both fine starts. Commit to one for 7 days so tool-hopping does not steal learning.
Do this now
Install one tool. Run their sample test. Screenshot the green result.
Automate login happy path
Visit, type, click, assert landing. Keep it ugly but clear. Names matter more than cleverness.
// Playwright example (concept applies to any tool)
await page.goto("https://www.saucedemo.com/");
await page.getByPlaceholder("Username").fill("standard_user");
await page.getByPlaceholder("Password").fill("secret_sauce");
await page.getByRole("button", { name: "Login" }).click();
await expect(page).toHaveURL(/inventory/);Do this now
Automate Sauce Demo login. Commit the file to your strategy repo under tests/exploratory/.
Break it on purpose
Change an assertion so it fails. Read the error. Fix. This trains debugging muscle.
Do this now
Fail → read → fix → note what the error taught you in 2 sentences in DEBUG-NOTES.md.
Negative path
Wrong password, empty fields, locked user — one negative case proves you assert errors, not just happy paths.
Do this now
Add a locked_out_user test. Assert error message text.