Latest
method Accessibility.prototype.snapshot
import { Accessibility } from "https://dotland.deno.dev/x/puppeteer@16.2.0/vendor/puppeteer-core/puppeteer/types.d.ts";

Captures the current state of the accessibility tree. The returned object represents the root accessible node of the page.

Examples

An example of dumping the entire accessibility tree:

const snapshot = await page.accessibility.snapshot();
console.log(snapshot);

An example of logging the focused node's name:

const snapshot = await page.accessibility.snapshot();
const node = findFocusedNode(snapshot);
console.log(node && node.name);

function findFocusedNode(node) {
  if (node.focused) return node;
  for (const child of node.children || []) {
    const foundNode = findFocusedNode(child);
    return foundNode;
  }
  return null;
}

Parameters

optional
options: SnapshotOptions

Returns

Promise<SerializedAXNode | null>

An AXNode object representing the snapshot.