TOPIC 38/6018 MINNOT STARTED

Aria snapshots: checking the page structure as a tree

Check the roles and names that make up a page, as a text tree, so a restyle does not break the test but a lost button or heading does.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: a building plan versus a photograph. A photograph of a house shows colours, light and the sofa. Paint the walls and the photograph is wrong. A plan shows rooms, doors and stairs. Paint the walls and the plan is still right. Knock out a door and the plan is wrong.

Tom tests the task page of Daily List, a to-do list app. Leo often changes colours and spacing. A picture check breaks each time. Tom wants that works like the plan.

The picture has limits. A plan shows no colour, size or place. It cannot tell Tom if a button is hidden behind a banner. For that he still needs another kind of check.

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: checking the page as a tree of roles and names. An is that tree written as text. The is the browser's second version of the page, built for a screen reader. A screen reader reads a page aloud. A children match mode says how strict the children must be: contain, equal or deep-equal. You check with toMatchAriaSnapshot. The nearest neighbour is toHaveScreenshot, which breaks when Leo only changes padding. The tree stays green for a restyle and fails when the Add task button disappears.

Why it matters: Screenshot checks train the team to update pictures until the test is quiet, including for a lost heading. An aria snapshot fails for a lost button or a changed order, and it stays calm when the colour changes. Tom can read the difference in a , because it is text, not a blob of pixels.

(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)

PLAIN WORDS · 4 in this section
playwright
a free Microsoft tool that drives a browser for tests
padding
extra filler added to fill a fixed length
restyle
to change how a page looks, not what it does
blob
a lump of data with no set shape

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 Checking the structure of a page, such as its headings, buttons and list items, without checking its looks.

  1. Look
  2. Write the tree
  3. Trim it
  4. Compare
Draw the plan, not the photo

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
A building planThe aria snapshot
The rooms and doorsThe roles and names
Paint and furnitureColours and layout
A plan with only the main rooms drawnA partial template

WHERE THIS PICTURE STOPS

  • A plan is drawn by an architect, but the tree is built by the browser from the page code.
  • A plan stays still, while a page changes with every user action.
  • Most plans show where a door is, but the tree shows no place at all.

HOOK

Plan, not photo.

REMEMBER IT THIS WAY

A contrast: two neighbours told apart by one test.

If the colours change and the check should still pass, check the roles and names, not a photo.

What each part of the trick stands for
In the trickWhat it stands for
planthe aria snapshot
photoa screenshot

A plan shows no place on the page, so it cannot catch a button that moved.

TELL A FRIEND

An is the plan of a page. It checks rooms and doors, not paint.

OFTEN MIXED UP WITH Accessibility testing basics. The earlier lesson explains why pages must work for people who use assistive tools. This lesson uses the same page structure as a test.

Sources & standards — 4 sources
  1. Market practice

    Snapshot testing with aria snapshots (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 aria snapshots as a YAML Ain't Markup Language (YAML) picture of the accessibility tree that is compared with an expected template using toMatchAriaSnapshot. A template is a set of constraints, not a full copy. Nodes are written as role, optional name and optional attributes in brackets; quoted text is exact and /patterns/ are regular expressions; matching is case-sensitive and order-sensitive; leaving out a name or attribute loosens the match.

    A /children property sets contain (default), equal or deep-equal. An empty template generates one, and templates can live in a .aria.yml file through the name option.

    Page-level assertions arrived in later versions than the first release of the feature. 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

    Accessible Rich Internet Applications (ARIA) 1.2 ↗ — World Wide Web Consortium (W3C) · Roles, names and states are defined in a standard (search excerpt, page not opened)

    Roles, states and properties, and which roles need an accessible name. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: World Wide Web Consortium (W3C) Recommendation, 2023. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  3. Market practice

    Using Accessible Rich Internet Applications (ARIA) (W3C Working Group Note) ↗ — World Wide Web Consortium (W3C) · A native element gives a role and a name without extra work (search excerpt, page not opened)

    The first rule of Accessible Rich Internet Applications (ARIA): use a native HyperText Markup Language (HTML) element when one gives the meaning and behaviour needed. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: World Wide Web Consortium (W3C) Working Group Note. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  4. Market practice

    Assertions (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.

    Locator/page web assertions re-read current state; generic value assertions do not retry. APIResponse toBeOK checks a fixed captured 2xx status once, as confirmed by the pinned 1.65 matcher implementation; broad guide grouping must not imply a request resend. Soft assertions retain failure state; poll/toPass repeat their callbacks with explicit side-effect and deadline considerations. · 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.

PRACTISE AND KEEP

Sources for this topic — 4 sources
  1. Market practice

    Snapshot testing with aria snapshots (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 aria snapshots as a YAML Ain't Markup Language (YAML) picture of the accessibility tree that is compared with an expected template using toMatchAriaSnapshot. A template is a set of constraints, not a full copy. Nodes are written as role, optional name and optional attributes in brackets; quoted text is exact and /patterns/ are regular expressions; matching is case-sensitive and order-sensitive; leaving out a name or attribute loosens the match.

    A /children property sets contain (default), equal or deep-equal. An empty template generates one, and templates can live in a .aria.yml file through the name option.

    Page-level assertions arrived in later versions than the first release of the feature. 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

    Accessible Rich Internet Applications (ARIA) 1.2 ↗ — World Wide Web Consortium (W3C) · Roles, names and states are defined in a standard (search excerpt, page not opened)

    Roles, states and properties, and which roles need an accessible name. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: World Wide Web Consortium (W3C) Recommendation, 2023. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  3. Market practice

    Using Accessible Rich Internet Applications (ARIA) (W3C Working Group Note) ↗ — World Wide Web Consortium (W3C) · A native element gives a role and a name without extra work (search excerpt, page not opened)

    The first rule of Accessible Rich Internet Applications (ARIA): use a native HyperText Markup Language (HTML) element when one gives the meaning and behaviour needed. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: World Wide Web Consortium (W3C) Working Group Note. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  4. Market practice

    Assertions (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.

    Locator/page web assertions re-read current state; generic value assertions do not retry. APIResponse toBeOK checks a fixed captured 2xx status once, as confirmed by the pinned 1.65 matcher implementation; broad guide grouping must not imply a request resend. Soft assertions retain failure state; poll/toPass repeat their callbacks with explicit side-effect and deadline considerations. · 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.

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.