Learn It Yourself
All courses · Dashboard › Testing with Playwright
Learn It YourselfWorking with ClaudeBeginner

Testing with Playwright

What an automatic test is, and how a robot visitor called Playwright checks your site on a computer and a phone before anyone else sees a problem. Then everything else it can do for you: screenshots, videos, PDFs, boring web chores, and giving Claude a pair of eyes. With real examples from this site.

Beginner 4 parts, 13 lessons Real examples 12 practice goals

What you'll learn

  • What an automatic test is, in plain words
  • Why tests catch problems before your visitors do
  • What Playwright is, and what a test looks like
  • How to read a failed test, step by step
  • Screenshots, videos, PDFs and web chores without testing
  • How Playwright lets Claude see and check its own work
How the course is built
Part 1 and 2: testingWhat tests are, and how Playwright runs them on this very site.
Part 3: beyond testingThe same robot visitor makes pictures, videos and PDFs, and does chores.
Part 4: in real lifeHow others use it, what to tell Claude, and a yes-or-no quiz.
The examples are real

This site has been tested with Playwright since 22 November 2026. The test results, screenshots, videos and the PDF on this page were all made by Playwright, from this site.

1

Testing in general

What a test is, why it helps, and the tool we use.

Lesson 01Reading

What is an automatic test?

Picture a very patient helper who visits your website after every change. They follow a checklist: open the home page, click a course, tick a practice goal, log in, change the name on the profile. After each step they check that the page did what it should. If anything is off, they tell you exactly which step went wrong.

An automatic test is that checklist, written down so a computer can do it. A test run goes through every checklist in a few seconds and ends with one of two words for each: passed or failed.

A friendly robot sitting in front of a web page with a clipboard of ticked boxes, while the smiling tile mascot waves next to the screen
A test is a checklist that a robot visitor follows, step by step, every time.

👀 Checking by hand

You click around yourself. It works, but it's slow, you'd have to do it after every change, and it's easy to forget the profile page when you only changed a course.

🤖 Automatic test

The computer clicks around for you. It never gets bored, never skips a page, and checks a phone screen and a computer screen at the same time.

Tests don't replace you

A test only checks what's on its checklist. It can say "the Save button works", but not "this colour is ugly". You still look at new things yourself; tests make sure the old things keep working.

Lesson 02Practice

Catching problems early

Every change can break something somewhere else. On 21 November 2026 a single apostrophe in the word "can't" stopped the whole profile page from working: the weekly email switch, the name and the reset button did nothing. Nobody noticed until you tried it.

Now, every time the site goes online, more than 70 tests run first. If one fails, nothing is uploaded. We put that exact apostrophe back on purpose, and three tests failed straight away with the message missing ) after argument list.

The tile mascot holding a net with a little bug caught in it, in front of a web page with a small warning sign
A bug caught by a test costs a minute. A bug found by visitors costs their trust.

Practise: this pretend test lab checks a small bakery order page. Run the tests after Claude's change to see one fail, then run them again after the fix.

mias-bakery.example / order
Order a birthday cakeChocolate cake: $35Your nameOrder
Press "Run the tests".
Try version 2, then version 3.
Lesson 03Reading

Meet Playwright

Playwright is the robot visitor. It's a free tool made by Microsoft that opens a real web browser and uses it the way a person would: it opens pages, clicks buttons, types into boxes, scrolls and reads what's on the screen. The only difference is that it does it in a split second, and usually without showing a window at all (that's called headless).

🌐Three browser enginesThe engines behind Chrome and Edge (Chromium), Firefox, and Safari (WebKit).
💻Any computerRuns on Windows, Mac and Linux. On your computer, Claude installed it in a minute.
🆓Free and openNo account, no subscription. Anyone can read and use its code (Apache 2.0 licence).
Where it lives on your site

In the tests folder of your project. You never open it: you say "run the tests", or just "go live", and Claude does the rest.

2

Playwright for testing

How a test is written, which screens it checks, and what you get when one fails.

Lesson 04Practice

What a test looks like

A test is a short list of actions and checks. Here is a real one from this site, with the same steps in plain words next to it. You'll never write this yourself; Claude does. But it helps to know it's just a checklist.

In plain words
  1. Open the profile page
  2. Type "Alex Tester" in the name box
  3. Click "Save name"
  4. Check: the page says "Saved."
  5. Open the GitHub Basics course
  6. Check: the top bar shows "Alex Tester"
What Claude wrote
await page.goto('/private/profile');await page.getByLabel('How should we call you?') .fill('Alex Tester');await page.getByRole('button', { name: 'Save name' }) .click();await expect(page.locator('#name-msg')) .toHaveText('Saved.');await page.goto('/github-basics');await expect(page.locator('[data-login]')) .toHaveText('Alex Tester');
It finds things like a person does

Notice "the button named Save name" and "the box labelled How should we call you?". Playwright looks for what's written on the screen, not hidden code, so the test keeps working when the design changes. It also waits by itself until a button is really there and clickable.

Practise: put the steps of a new test in the right order. Click them from first to last.

Click the first step.
Lesson 05Reading

Computer, phone and more

Playwright can pretend to be many kinds of visitor without owning any of those devices. On this site, every test runs twice: once on a computer screen and once as a Pixel 7 phone. That's how we found that two courses were too wide for phones.

The same smiling page on a big monitor, a laptop and a phone, with the mascot pointing at the screens
One test, many screens: Playwright pretends to be each device.
📱Phones and tabletsReady-made sizes for popular iPhones, Pixels and iPads, including touch.
🌙Dark modeSee the site the way someone with dark mode switched on sees it.
🗺️Place, language, timePretend to be in Paris, in French, at midnight. Handy for opening hours or prices.
📴No internetCheck what a visitor sees when their connection drops.
🦊Other browsersThe same checks in Chrome, Firefox and Safari's engine.
♿AccessibilityWith a free add-on (axe), check for problems that affect people using screen readers.
Pretend, not real

A pretend phone has the right screen size and touch, but it isn't a real iPhone in your hand. For something important, still have a quick look on your own phone.

Lesson 06Practice

When a test fails

When a test fails, Playwright doesn't just say "failed". It keeps evidence: a screenshot of the moment it went wrong, and a trace, a step-by-step recording you can replay like a video, with what the page looked like at each step. Claude reads these to find the cause.

Running 72 tests using 4 workers ✓ [computer] › / looks right ✘ [computer] › /private/profile looks right Error: script errors or broken files on /private/profile + "script error: missing ) after argument list" screenshot: results/…/test-failed-1.png trace: results/…/trace.zip 3 failed 68 passed (36s)

Practise: this is a pretend trace of the failed name test. Click through the steps and find the one that went wrong.

    Pick a step on the leftEach step shows what the page looked like at that moment.
    Find the step that failed.
    3

    Beyond testing

    The same robot visitor is good at much more than checking.

    Lesson 07Reading

    Screenshots and videos

    The smiling tile mascot jumping out of a laptop, juggling a camera, a film reel, a document and a little chart
    Pictures, films, documents: the robot visitor can make all of them.

    Because Playwright really opens your pages, it can photograph them: the visible part, the whole page from top to bottom, or just one box. These two were made by Playwright from this site's home page:

    Screenshot of the Learn It Yourself home page on a computer screen
    Computer screen, 1280 pixels wide
    Screenshot of the Learn It Yourself home page on a phone screen
    Phone (Pixel 7)

    It can also record a video of everything it does. These are real recordings of two made-up members on a test copy of this site: they log in with an email code, answer quiz questions wrong and then right, change their name, and check that everything was saved.

    Anna on a computer (about 1½ minutes)
    Ben on a phone (about 1 minute)
    🖼️Picture comparisonsPlaywright can keep a "this is how it should look" picture of each page, and flag any page that suddenly looks different.catches design slips
    📚Fresh pictures for guidesHelp pages and course lessons always show today's screens, re-made automatically after each change.no more outdated screenshots
    Lesson 08Reading

    Web chores and PDFs

    Anything you do in a browser by clicking and typing, Playwright can do for you, on a schedule if you like. That makes it handy for small, boring jobs:

    📄Save a page as a PDFA print-ready document of any page. Here is the GitHub Basics course as an 8-page PDF, made by Playwright in about two seconds.
    📝Fill in formsType the same details into a web form every week, such as a booking or a timesheet.
    ⬇️Download reportsLog in to your own account and download this month's invoice or statement.
    🔔Watch a pageCheck a page every morning and tell you when something changes: a price, a stock level, a new post.
    📋Collect informationCopy a table from a web page into a spreadsheet, so nobody has to retype it.
    🚦Check the live siteEvery hour, open your live site and tell you if it's down, before a visitor does.
    Be a polite robot

    Use it on your own sites and your own accounts. Many websites don't allow robots in their rules, and some block them. Keep passwords for these jobs in piy-sops, never in the code. If in doubt, ask Claude to check the site's rules first.

    Lesson 09Reading

    Giving Claude eyes

    Claude writes your pages, but on its own it can't see them. Playwright changes that. Claude can open the page, take a screenshot, look at it, click around, and notice "the button is hidden behind the footer on phones", then fix it and look again. That's how the design problems on this site were found: Claude screenshotted every page on a computer and a phone, and looked.

    There are two ready-made ways to give an AI helper a browser:

    🔌 Playwright MCP

    An add-on that gives Claude its own browser to use while you chat. It reads a page's structure the way a screen reader does (fast and exact), and can click, type, fill forms and take screenshots. Claude installs it with one command, and it's free.

    🧑‍🔧 Test agents

    Playwright comes with three AI helpers: a planner that explores a site and writes a test plan, a generator that turns the plan into tests, and a healer that fixes tests that broke after a change.

    How this helps us work together

    You describe what you see ("the login button does nothing on my phone"). Claude opens the same page as a phone, reproduces it, fixes it, writes a test so it can't come back, and sends you a screenshot or video to approve. You check results, not code.

    4

    In real life

    How others use it, what to say to Claude, and a quiz.

    Lesson 10Practice

    How people use it

    🏢Software teamsBig companies run thousands of tests every time someone changes the code, often on GitHub, before anything reaches customers.
    🛒Online shopsEvery few minutes a robot adds something to the basket and goes to checkout, so a broken checkout is noticed in minutes, not days.
    ✍️Help-guide writersScreenshots in their guides are re-made automatically whenever the app changes.
    📊Office workWeekly reports downloaded, forms filled, pages saved as PDFs, all without anyone clicking.
    ♿Accessibility checksPages are scanned for problems that block people using screen readers or keyboards.
    🤖AI helpers like ClaudeUsing a browser to check their own work, and to do web tasks you ask for.

    Practise: which Playwright skill fits each job?

    Answer all five.
    Lesson 11Reading

    What to say to Claude

    You never need to know the commands. These are things you can just say:

    Before going live"Run the tests." or just "Go live." (the tests run first anyway)
    A new feature"Add the new contact form, and a test that it really sends."
    You spotted a bug"On my phone the menu covers the title. Reproduce it with Playwright, fix it, and add a test so it doesn't come back."
    To see it yourself"Send me screenshots of the dashboard on a computer and a phone." or "Record a short video of someone logging in."
    A chore"Every Monday, save my supplier's price list page as a PDF."
    A check-up"Look at every page on a phone and tell me what looks wrong."
    A good habit

    When something breaks, ask for a test that catches it along with the fix. Each bug then becomes one more thing that's checked forever.

    Lesson 12Quiz

    Can Playwright do this?

    Eight business situations. For each one, answer yes if Playwright is the right tool, or no if it isn't.

    Lesson 13Reference

    Cheat sheet and words

    Words in this course

    Test
    a checklist a computer follows
    Test run
    doing every checklist once
    Pass / fail
    did every check come out right?
    Headless
    a browser with no window
    Trace
    a step-by-step replay of a test
    Flaky test
    passes sometimes, fails sometimes

    What Playwright can do

    Test
    click, type and check pages
    Screens
    phones, dark mode, other places
    Pictures
    screenshots, whole page or one box
    Video
    record a whole visit
    PDF
    save a page as a document
    Chores
    forms, downloads, page watching

    On your site

    Tests
    over 70, about 35 seconds
    Screens
    computer and Pixel 7 phone
    When
    before and after every go-live
    Members
    made-up test members, nothing sent
    Cost
    free

    What it can't do

    Visitors
    count them: that's analytics
    Taste
    say if a design is nice
    Fixing
    it finds problems; Claude fixes
    Real phones
    it pretends, it doesn't hold one
    Does Playwright cost anything?

    No. It's free and open source. It runs on your own computer, so there's nothing to pay and no account to make.

    Does it slow down my website?

    No. The tests run on your computer, mostly on a test copy of the site. Visitors never notice them.

    Will tests ever send real emails or change real members?

    Not on your site. The tests use a test copy with made-up members, and login emails are caught instead of sent. After going live, the tests only look at public pages.

    A test failed but the site looks fine. Now what?

    Tell Claude. Sometimes the site is broken in a way you didn't notice yet; sometimes the test itself needs updating after a planned change. The screenshot and trace show which one.

    Can Playwright test on my real iPhone?

    It pretends to be one: the right screen size, touch, and Safari's engine. That catches most problems. For something important, still look on your own phone once.