Core Concepts
Snapshots
Snapshot modes, counter semantics, and best practices.
Pipeline
Snapshots follow a four-stage pipeline:
- Mark elements in the live DOM.
- Serialize the HTML.
- Clean with a mode-specific cleaner.
- Assign counters.
Modes
| Mode | Use | Includes |
|---|---|---|
action | Before click/input/select/scroll | Interactive elements with counters |
extraction | Before extract | Data-bearing elements with counters |
clickable | Identify clickable targets | Only clickable elements |
scrollable | Identify scrollable regions | Only scrollable containers |
full | Complete page structure | All elements |
await opensteer.snapshot({ mode: 'action' })
await opensteer.snapshot({ mode: 'extraction' })
Counter semantics
Counter values (c) follow these rules:
- Assigned fresh on every
snapshot()call. - Snapshot HTML and live DOM share the same
cvalues. - Action lookup: strict unique match. No match returns not found; multiple matches return ambiguous.
- Extraction lookup: tolerant. No match returns
null; multiple matches fail as ambiguous. - Boundary wrappers (
os-iframe-root,os-shadow-root) may be unnumbered. - Inaccessible iframes and closed shadow roots are not counter-addressable.
Best practices
- Re-snapshot before counter-based actions after page navigation or significant DOM changes.
- Use
actionmode before interactions,extractionmode before data extraction. - The
fullmode returns the largest payload. Use it only when you need complete page structure.
