TOPIC 25/6016 MINNOT STARTED

Screenshots and visual comparisons

Teach a Playwright test to take a picture of a page, compare it with a saved one, hide moving parts and update the saved picture on purpose.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: spot-the-difference between two photographs. You have two photos of the same room. One was taken last week. One was taken today. You lay them side by side and look for what moved. A lamp is gone. A chair is turned.

Daily List is a to-do list app. Leo changes the style of the home page on Monday. Tom, the tester, wants to know if anything looks wrong. Reading the code will not tell him. He needs to see the page.

The picture has limits. A person spots a lamp at once. A program only counts dots that changed. It cannot tell a lamp from a shadow. Fonts and moving parts play that part in a browser.

What it is: Playwright is a free library from Microsoft that drives a real browser from code. This topic is one slice of that library: pictures of a page. A is await expect(page).toHaveScreenshot('home.png'). It compares a new picture with a saved one. A covers a moving part, such as today's date, so that part is ignored. A snapshot update replaces the saved picture on purpose, with npx playwright test --update-snapshots. The nearest neighbour is toHaveText, which checks words and ignores colour, spacing and layout.

Why it matters: A wording check can pass while the cards overlap or a button falls off the screen. Mei needs proof of a layout break that a can miss. Without a saved picture, Tom has only his memory of how the page looked last week. With one, a failed run shows the old picture, the new picture and the difference.

(SYNTHETIC / TRAINING ONLY: Daily List, the site daily-list.example and every person named in this lesson are invented.)

PLAIN WORDS · 1 in this section
playwright
a free Microsoft tool that drives a browser for tests

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.

THE REAL JOB A test that photographs the page and compares it with a saved photo, then lets a person decide what to keep.

  1. Take the photo
  2. Compare it
  3. Cover the moving part
  4. Look, then update
Look, then swap the photo

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
Last week's photoThe saved picture
Today's photoThe new screenshot
A tape over a moving clockThe mask
Putting today's photo in the frameThe snapshot update

WHERE THIS PICTURE STOPS

  • A person understands a room. A test counts dots.
  • A photo has light. A page has fonts and motion.
  • Swapping the photo in the frame is a choice. Nobody should do it by reflex.

HOOK

Look, then swap the photo.

REMEMBER IT THIS WAY

A contrast: two neighbours told apart by one test.

Ask two questions when a picture check fails: did the page change on purpose, or is it only moving parts? Update the saved picture only after the first answer.

What each part of the trick stands for
In the trickWhat it stands for
on purposethe snapshot update
moving partsthe mask over what moves

Fonts and motion can fail a picture check even when nothing is wrong.

TELL A FRIEND

Two photos of one room, side by side. You swap the old one only when you want the new room.

OFTEN MIXED UP WITH Visual regression testing. The visual regression lesson explains baselines and thresholds in any tool. This lesson shows the Playwright calls.

Sources & standards — 4 sources
  1. Market practice

    Visual comparisons (Playwright documentation) ↗ — Microsoft · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Describes comparing a screenshot with a saved baseline and the threshold, maxDiffPixels and maxDiffPixelRatio options. Vendor documentation for one tool. Practitioner guidance, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  2. Market practice

    ISTQB Certified Tester Foundation Level Syllabus v4.0.1 ↗ — International Software Testing Qualifications Board · Section 6.2, Benefits and Risks of Test Automation: a tool needs ongoing effort to give lasting benefits, and its risks need analysis and mitigation (confirmed against the syllabus, read in full text from a mirror copy of the publisher PDF, v4.0.1, 15 September 2024)

    The examinable statement of what a foundation-level tester is expected to know: six chapters, 64 learning objectives, each tagged K1 Remember, K2 Understand or K3 Apply, plus the test-design techniques the qualification names and groups as black-box, white-box and experience-based.

    Used here for the test-craft questions a Payment Quality Assurance Analyst and a Production Support Analyst are asked. It is cited for what the syllabus says a tester must be able to do, never as a rule about how payments work. · Checked 2026-11-07

    v4.0.1 is dated 15 September 2024 and is a list of corrections to v4.0 (21 April 2023) that reworded six learning objectives — not a cosmetic reissue. 78 pages.

    Two traps this entry exists to stop. v4.0.2 is the German edition (1 March 2025, 94 pages), so sorting by version number reaches the wrong document. And the widely-repeated per-chapter question allocation "8 / 5 / 4 / 11 / 9 / 3" is wrong: it is 8 / 6 / 4 / 11 / 9 / 2, derived from three official sample-exam answer keys and confirmed against the Exam Structure Tables.

    The single most consequential detail for a question bank: white-box coverage — statement and branch — is K2 "Explain", not K3 "Apply" (FL-4.3.1, FL-4.3.2, FL-4.3.3), and MC/DC, path and condition coverage are declared out of scope in §4.3. A question asking a candidate to compute branch coverage is testing something this syllabus does not.

    Read through a mirror, because the publisher's own domain could not be fetched (a reachability gap, not a statement about the publisher). A 403 there is a policy refusal and says nothing about whether the document exists or is reachable elsewhere.

    Anyone on an unrestricted network should open the canonical URL above and confirm the section and page numbers cited against it. Every claim drawn from this entry is written so that it can be checked against a numbered page.

    Read from two independent PDF-to-markdown conversions mirrored on raw.githubusercontent.com. They are treated as faithful because they were produced by unrelated parties with different tooling, agree on the full 64-item objective set including wording, and reproduce the same internal inconsistency present in the source PDF. Chapter 1 reads "testware that supports" where Appendix B reads "that support". A conversion artefact does not replicate across two toolchains.

    The licence permits attributed non-commercial extracts and use as the basis for articles. Whether a site that sells a pass may rely on that is an owner's decision, not this entry's.

    7 November 2026 review: actual publisher PDF 4.0.1, 15 September 2024, 78 pages, front matter/copyright and relevant numbered operative sections 0.5–0.10 and chapters 1–6 compared with CTFLpractice lessons. Earlier mirror/search descriptions are historical access records. TheK2 white-box objectives require explanation; the source does not justify a categorical ban on small numeric illustrations that support explanation. Later Exam Rules 1.2§4.1.4 usesK2 for keyword definitions, while syllabus§0.5 usesK1; keep dated scopes distinct. No copied questions or figure assets.

  3. Market practice

    Configuration (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Describes playwright.config.ts, testDir, the use block, the webServer setting and forbidOnly, which makes a run fail when a test or group is marked only and suits CI. Vendor documentation, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  4. Market practice

    LocatorAssertions | Playwright ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: toHaveScreenshot overloads. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    toHaveScreenshot overloads · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: toHaveScreenshot overloads. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

PRACTISE AND KEEP

Sources for this topic — 4 sources
  1. Market practice

    Visual comparisons (Playwright documentation) ↗ — Microsoft · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Describes comparing a screenshot with a saved baseline and the threshold, maxDiffPixels and maxDiffPixelRatio options. Vendor documentation for one tool. Practitioner guidance, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  2. Market practice

    ISTQB Certified Tester Foundation Level Syllabus v4.0.1 ↗ — International Software Testing Qualifications Board · Section 6.2, Benefits and Risks of Test Automation: a tool needs ongoing effort to give lasting benefits, and its risks need analysis and mitigation (confirmed against the syllabus, read in full text from a mirror copy of the publisher PDF, v4.0.1, 15 September 2024)

    The examinable statement of what a foundation-level tester is expected to know: six chapters, 64 learning objectives, each tagged K1 Remember, K2 Understand or K3 Apply, plus the test-design techniques the qualification names and groups as black-box, white-box and experience-based.

    Used here for the test-craft questions a Payment Quality Assurance Analyst and a Production Support Analyst are asked. It is cited for what the syllabus says a tester must be able to do, never as a rule about how payments work. · Checked 2026-11-07

    v4.0.1 is dated 15 September 2024 and is a list of corrections to v4.0 (21 April 2023) that reworded six learning objectives — not a cosmetic reissue. 78 pages.

    Two traps this entry exists to stop. v4.0.2 is the German edition (1 March 2025, 94 pages), so sorting by version number reaches the wrong document. And the widely-repeated per-chapter question allocation "8 / 5 / 4 / 11 / 9 / 3" is wrong: it is 8 / 6 / 4 / 11 / 9 / 2, derived from three official sample-exam answer keys and confirmed against the Exam Structure Tables.

    The single most consequential detail for a question bank: white-box coverage — statement and branch — is K2 "Explain", not K3 "Apply" (FL-4.3.1, FL-4.3.2, FL-4.3.3), and MC/DC, path and condition coverage are declared out of scope in §4.3. A question asking a candidate to compute branch coverage is testing something this syllabus does not.

    Read through a mirror, because the publisher's own domain could not be fetched (a reachability gap, not a statement about the publisher). A 403 there is a policy refusal and says nothing about whether the document exists or is reachable elsewhere.

    Anyone on an unrestricted network should open the canonical URL above and confirm the section and page numbers cited against it. Every claim drawn from this entry is written so that it can be checked against a numbered page.

    Read from two independent PDF-to-markdown conversions mirrored on raw.githubusercontent.com. They are treated as faithful because they were produced by unrelated parties with different tooling, agree on the full 64-item objective set including wording, and reproduce the same internal inconsistency present in the source PDF. Chapter 1 reads "testware that supports" where Appendix B reads "that support". A conversion artefact does not replicate across two toolchains.

    The licence permits attributed non-commercial extracts and use as the basis for articles. Whether a site that sells a pass may rely on that is an owner's decision, not this entry's.

    7 November 2026 review: actual publisher PDF 4.0.1, 15 September 2024, 78 pages, front matter/copyright and relevant numbered operative sections 0.5–0.10 and chapters 1–6 compared with CTFLpractice lessons. Earlier mirror/search descriptions are historical access records. TheK2 white-box objectives require explanation; the source does not justify a categorical ban on small numeric illustrations that support explanation. Later Exam Rules 1.2§4.1.4 usesK2 for keyword definitions, while syllabus§0.5 usesK1; keep dated scopes distinct. No copied questions or figure assets.

  3. Market practice

    Configuration (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Describes playwright.config.ts, testDir, the use block, the webServer setting and forbidOnly, which makes a run fail when a test or group is marked only and suits CI. Vendor documentation, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  4. Market practice

    LocatorAssertions | Playwright ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: toHaveScreenshot overloads. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    toHaveScreenshot overloads · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: toHaveScreenshot overloads. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.