Accessibility snapshot with numbered element refs.
Walks the DOM tree via JavaScript injection and builds a YAML-like
accessibility tree with stable refs (e1, e2, f1_e1 for iframes).
Elements are tagged with data-pw-ref attributes for later interaction.
Usage: (def snap (capture-snapshot page)) (:tree snap) ;; YAML-like string with [@eN] annotations (:refs snap) ;; {"e1" {:role "button" :name "Submit" :bbox {...}} ...} (resolve-ref page "e3") ;; returns Locator for the element
Accessibility snapshot with numbered element refs.
Walks the DOM tree via JavaScript injection and builds a YAML-like
accessibility tree with stable refs (e1, e2, f1_e1 for iframes).
Elements are tagged with `data-pw-ref` attributes for later interaction.
Usage:
(def snap (capture-snapshot page))
(:tree snap) ;; YAML-like string with [@eN] annotations
(:refs snap) ;; {"e1" {:role "button" :name "Submit" :bbox {...}} ...}
(resolve-ref page "e3") ;; returns Locator for the element(capture-full-snapshot page)Captures a snapshot of the page and all its iframes.
Combines main frame and iframe snapshots into a unified tree.
Params:
page - Playwright Page instance.
Returns: Map with :tree, :refs, :counter covering all frames.
Captures a snapshot of the page and all its iframes. Combines main frame and iframe snapshots into a unified tree. Params: `page` - Playwright Page instance. Returns: Map with :tree, :refs, :counter covering all frames.
(capture-snapshot page)(capture-snapshot page opts)Captures an accessibility snapshot of the page with numbered refs.
Injects JavaScript to walk the DOM, compute ARIA roles and names, assign data-pw-ref attributes, and collect bounding boxes.
Params:
page - Playwright Page instance.
opts - Map, optional.
:scope - String. CSS selector or snapshot ref (@e1, e1) to scope the
snapshot to a subtree. When provided, only elements within the
matched element are included in the tree and refs.
If the selector matches nothing, returns an empty snapshot.
Returns: Map with: :tree - String. YAML-like accessibility tree with [@eN] annotations. :refs - Map. {"e1" {:role "button" :name "Submit" :bbox {:x :y :width :height}} ...} :counter - Long. Total number of refs assigned.
Captures an accessibility snapshot of the page with numbered refs.
Injects JavaScript to walk the DOM, compute ARIA roles and names,
assign data-pw-ref attributes, and collect bounding boxes.
Params:
`page` - Playwright Page instance.
`opts` - Map, optional.
:scope - String. CSS selector or snapshot ref (@e1, e1) to scope the
snapshot to a subtree. When provided, only elements within the
matched element are included in the tree and refs.
If the selector matches nothing, returns an empty snapshot.
Returns:
Map with:
:tree - String. YAML-like accessibility tree with [@eN] annotations.
:refs - Map. {"e1" {:role "button" :name "Submit" :bbox {:x :y :width :height}} ...}
:counter - Long. Total number of refs assigned.(capture-snapshot-for-frame _frame frame-ordinal)Captures an accessibility snapshot for a specific frame.
Refs are prefixed with the frame ordinal: f1_e1, f2_e3, etc.
Params:
frame - Playwright Frame instance.
frame-ordinal - Long. Frame index (1-based).
Returns: Same format as capture-snapshot, but with prefixed refs.
Captures an accessibility snapshot for a specific frame. Refs are prefixed with the frame ordinal: f1_e1, f2_e3, etc. Params: `frame` - Playwright Frame instance. `frame-ordinal` - Long. Frame index (1-based). Returns: Same format as capture-snapshot, but with prefixed refs.
(clear-refs! page)Removes all data-pw-ref attributes from the page.
Params:
page - Playwright Page instance.
Removes all data-pw-ref attributes from the page. Params: `page` - Playwright Page instance.
(ref-bounding-box refs ref-id)Returns the bounding box for a ref from the last snapshot.
Params:
refs - Map of refs from capture-snapshot.
ref-id - String. Ref like "e1".
Returns: Map {:x :y :width :height} or nil.
Returns the bounding box for a ref from the last snapshot.
Params:
`refs` - Map of refs from capture-snapshot.
`ref-id` - String. Ref like "e1".
Returns:
Map {:x :y :width :height} or nil.(resolve-ref page ref-id)Resolves a ref ID to a Playwright Locator.
The element must have been tagged with data-pw-ref during capture-snapshot.
Params:
page - Playwright Page instance.
ref-id - String. Ref like "e1", "e2", etc.
Returns: Locator instance for the element.
Resolves a ref ID to a Playwright Locator. The element must have been tagged with data-pw-ref during capture-snapshot. Params: `page` - Playwright Page instance. `ref-id` - String. Ref like "e1", "e2", etc. Returns: Locator instance for the element.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |