@wdio/snapshot
Accessibility-style snapshots of web pages and native apps for WebdriverIO
Last updated 21 days ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @wdio/snapshot 
SYNC missed versions from official npm registry.

WebdriverIO Snapshot

Accessibility-style snapshots of web pages and native apps.

@wdio/snapshot turns a page (or an Appium page source) into a compact text tree with stable element refs. It is the engine behind wdio session snapshot and is shared with the devtools element picker, so its API is kept small.

Install webdriverio next to this package: it is a required peer dependency.

import { collectWeb, formatSnapshot, RefRegistry } from '@wdio/snapshot'

const refs = new RefRegistry()
const { tree, counter } = await collectWeb(browser, { counter: refs.counter, all: false, boxes: false }, { transport: 'classic-first' })
console.log(formatSnapshot(tree, { interactive: true }))

Web

  • collectWeb(browser, options, how) collects the page tree and returns { tree, counter, refs }. how.scope limits it to the subtree of an element, how.transport is 'classic-first' or 'bidi'.
  • collectScript(options) returns the collector as one self-contained expression for any page-eval API (page.evaluate, Runtime.evaluate).

Options (CollectOptions, without the role table, which the package adds):

Option Meaning
counter, all, boxes, urls first ref number, include non-interactive nodes, include bounding boxes, include link URLs
assignRefs true (default in collectWeb) stores refs in window.__wdioSession so they resolve later; false assigns none; 'ephemeral' numbers refs and computes candidates but stores nothing
viewport keep only what overlaps the viewport
extendedCandidates also compute aria-label, type, class and xpath-text selector candidates (extra page-side work)

Native

  • nativePlatform(capabilities, target?) returns 'android' | 'ios' | 'mac' | 'windows'.
  • parseNativeSource(xml, platform, { all?, counter? }) returns { tree, refs, located, counter }.
  • scopeNativeTree(tree, located, scope) narrows a native tree to a scope.

Trees and text

  • formatSnapshot(tree, options?) renders the tree as text. Options: depth, interactive, boxes, compact, selectors, and frameHint(ref), the command printed for cut and cross-origin iframes (without it the notes carry no instruction).
  • onlyInteractive(node), inViewport(node, width, height), attachSelectors(tree, refs), countRefs(text).
  • diffLines(a, b) and unifiedDiff(before, after, context?) compare snapshot text.
  • Types: SnapshotNode, SnapshotRef, SnapshotCandidate, CandidateKind, FormatOptions, CollectOptions, CollectResult, CollectHow, CollectWebResult, ParsedNative, Located, NativePlatform.

Refs and errors

  • RefRegistry keeps RefEntry records, resolves a ref to an element and derives a stable selector. refId(value) normalizes e12 and @e12.
  • SnapshotError has a code and an optional hint.

Current Tags

  • 10.2.0                                ...           latest (21 days ago)
  • 10.2.0-alpha.100.sha-b38abd894                                ...           next (a month ago)

8 Versions

  • 10.2.0                                ...           21 days ago
  • 10.2.0-alpha.100.sha-b38abd894                                ...           a month ago
  • 10.1.0                                ...           a month ago
  • 10.0.2                                ...           2 months ago
  • 10.1.0-alpha.30                                ...           2 months ago
  • 10.1.0-alpha.29                                ...           2 months ago
  • 10.1.0-alpha.26                                ...           2 months ago
  • 10.0.0-pre                                ...           2 months ago
Downloads
Total 27
Today 0
This Week 1
This Month 27
Last Day 0
Last Week 10
Last Month 0
Dependencies (1)
Dev Dependencies (1)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE