Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/pptr/mod.ts>Accessibility#snapshot

Headless Chrome Deno API
Latest
method Accessibility.prototype.snapshot
Re-export
import { Accessibility } from "https://deno.land/x/pptr@1.2.0/mod.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 = [UNSUPPORTED]

Returns

An AXNode object representing the snapshot.