sincecutoff.com
← all changes

Locator and page aria snapshots can return JSON

Introduced 2026-09-04 · score 0.97

HOW TO USE IT

When a test or inspection script needs a structured accessibility snapshot, call `locator.ariaSnapshotJSON()` or `page.ariaSnapshotJSON()`; pass optional `mode`, `depth`, or `boxes` options as needed. Both APIs were added in Playwright v1.63.0.

const snapshot = await page.getByRole('list').ariaSnapshotJSON();
const snapshot = await page.ariaSnapshotJSON({ mode: 'ai', depth: 2, boxes: true });

WHY THIS HELPS

Consume an aria snapshot as structured JSON in a test or inspection script.

BEFORE THIS CHANGE

Use the aria snapshot API that returns YAML markup.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.63.0
  • mode: `"ai"` or `"default"`; `"ai"` returns a snapshot optimized for AI consumption. Defaults to `"default"`.
  • depth: Number; limits the snapshot depth when specified.
  • boxes: Boolean; when true, adds each element's bounding box as a `box` property (`x`, `y`, `width`, `height`), in viewport-relative CSS pixels. Defaults to false.
  • Prerequisite: Use Playwright v1.63 or later; both methods were added in v1.63.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card