Playwright practice for beginners: a four-week plan

7 min read · TypeScript · 24 linked exercises

Reading the Playwright docs teaches you the API. Practice teaches you what to do when a locator matches three buttons, an element loads late or a form sits inside an iframe. This plan takes you from an empty folder to a full end-to-end suite in four weeks, at about four to five hours a week.

Every exercise runs against this site, so there's nothing to install except Playwright itself. Each one has a brief with the steps to test and a full solution to compare with yours when you're done.

Before you start: set up a project

You need Node.js 20 or newer. Create a project in an empty folder and accept the defaults (TypeScript, a tests folder):

npm init playwright@latest

Then point the tests at this site, so page.goto('/basic/buttons') opens the exercise. In playwright.config.ts:

export default defineConfig({
  use: {
    baseURL: 'https://playwright-playground.com',
  },
});

Three commands cover most of your day:

npx playwright test            # run every test
npx playwright test --ui       # UI mode: watch, step through, pick locators
npx playwright show-report     # the HTML report of the last run

Write one test file per exercise, for example tests/buttons.spec.ts. Mark the exercise as solved on its page when your test passes. Your progress is kept in the browser, with no account.

Week 1: locators, actions and assertions

Learn the core loop of every test: find an element, act on it, and assert the result. Use getByRole and getByLabel from day one, and always await your expect calls.

Practise it
  • ButtonsBeginnerClick, double-click and right-click, and why { exact: true } matters.
  • InputsBeginnerFill text, email, number, date and range inputs.
  • CheckboxesBeginnercheck(), uncheck() and setChecked().
  • Radio ButtonsBeginnerRadio groups and disabled options.
  • DropdownBeginnerNative selects and a custom dropdown.
  • Content & AttributesBeginnerAssert text, values, attributes and state.

By the end of the week, read the locators guide and try the Locator Challenges.

Week 2: forms, waiting and dialogs

Real forms validate, load data late and show dialogs. This week you'll stop reaching for waitForTimeout(): Playwright waits for you, if you let it.

Practise it

The auto-waiting guide explains what Playwright waits for and why tests turn flaky.

Week 3: tables, frames, files and windows

The harder parts of real apps: data in tables, forms in iframes, files going in and out, and links that open new tabs.

Practise it

Week 4: the network and a full end-to-end suite

Finish with what real test suites spend most of their effort on: controlling the network, reusing a signed-in session, and testing a complete shop from search to order confirmation.

Practise it

Habits that make the practice stick

  • Write the test before you open the solution. Struggling with a locator for ten minutes teaches more than reading the answer.
  • Make it fail on purpose. Change an expected value and read the error. You'll need to read errors like it at work.
  • Run it 20 times. --repeat-each=20 finds flaky tests before CI does.
  • Read failures with a trace. Run with --trace on and open the Trace Viewer instead of adding console logs.
Practise it

Exercises in this guide

More guides