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.
- Look
- Write the tree
- Trim it
- Compare
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| A building plan | The aria snapshot |
| The rooms and doors | The roles and names |
| Paint and furniture | Colours and layout |
| A plan with only the main rooms drawn | A 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.
| In the trick | What it stands for |
|---|---|
| plan | the aria snapshot |
| photo | a 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
- 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.
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.
- 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)
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.
- 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)
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.
- 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.
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
- 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.
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.
- 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)
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.
- 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)
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.
- 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.
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.