Skip to content

How the DOM maps to elements ​

toets matchers work on platform-neutral element snapshots. The web driver fills them from the DOM, reading the whole page in one script per call (no per-element round trips) and never waiting: the core retries.

FieldSource
testIddata-testid (or testIdAttribute)
textText of rendered descendants, whitespace-collapsed; form fields report their value
labelaria-label, else aria-labelledby text, else alt of images
boundsgetBoundingClientRect() in CSS pixels
visibleHas a box, non-zero size, not display: none / visibility: hidden (opacity is ignored)
inViewportVisible and intersecting the viewport after clipping by overflow ancestors (e.g. a rail)
focusableHas a tabindex (including -1) or is natively focusable, and not disabled or inert
focuseddocument.activeElement (through open shadow roots)
focusWithinThe element or a descendant is focused
enabledNot :disabled and no aria-disabled="true" on it or an ancestor
selectedaria-selected="true" (or a selected <option>)
busyaria-busy="true" on it or a descendant

Elements are walked in the rendered (flat) tree: open shadow roots and slots are followed; script, style, template and SVG internals are skipped; iframes are not entered. Selector chains are evaluated in the page with exactly the semantics of the core's evaluateChain (what every other driver and the SDK path use; a parity test enforces it): text selectors match the deepest elements whose text matches, like Playwright, and nth picks among the previous step's matches.

A hidden element still reports its full text, so getByText('Loading') finds a hidden spinner and not.toBeVisible() can pass.