Page Interaction
This page explains how Explorbot agents read a web page and act on it — and the two things you can change to help them: filtering noisy HTML and marking custom components.
How agents see a page
Section titled “How agents see a page”Agents read each page three ways at once:
| Source | What it gives | Used for |
|---|---|---|
| ARIA snapshot | Roles, labels, states, hierarchy | Understanding structure, building locators |
| HTML | Classes, IDs, data attributes, form fields | Precise locators, reading field values |
| Screenshot | Layout, colors, icons, coordinates | Visual checks, click fallbacks |
The accessibility tree is the primary source. HTML adds detail. The screenshot is a fallback when the first two aren’t enough.
Filter noisy HTML
Section titled “Filter noisy HTML”Agents work from the combined HTML snapshot. Cookie banners, chat widgets, ads, and analytics tags add noise and burn tokens. Exclude them in your config:
html: { combined: { include: ['*'], exclude: ['script', 'style', 'svg', '.cookie-banner', '.analytics-tracker'], },}Three snapshots exist, each configurable:
| Snapshot | Purpose | Config key |
|---|---|---|
combined | Main HTML for agents | html.combined |
minimal | Interactive elements only | html.minimal |
text | Text content only | html.text |
Mark custom components
Section titled “Mark custom components”Some components are interactive but have no ARIA role or semantic HTML, so agents miss them. Mark them with a data-explorbot-* attribute:
<div data-explorbot-role="button" data-explorbot-label="Save Draft"> <svg>...</svg> Save</div>A marked element is always kept in snapshots, treated as interactive, and shown to agents. During processing, data-explorbot-role="button" becomes role="button", so you add a hint without changing how your component behaves.
Use this when standard locators fail to find an element, or when a custom control isn’t detected as interactive.
Locator priority
Section titled “Locator priority”When an agent picks a locator, it prefers the most stable option first:
flowchart LR
A[ARIA, semantic text, and role] --> B[Scope with a container]
B --> C[HTML attributes, CSS, or XPath]
C --> D[Screenshot and visual coordinates]
The agent starts with short semantic locators from ARIA or visible text. When a match is ambiguous, it scopes that locator to a container before moving to HTML-based selectors and, finally, visual coordinates.
- Short ARIA or text —
I.click({ role: 'button', text: 'Save' })orI.click('Save')when it is unique - Text with a container —
I.click('Save', '.modal')— simplest and preferred when a container is known - ARIA with a container —
I.click({ role: 'button', text: 'Save' }, '.modal')— for semantic disambiguation - CSS or XPath —
I.click('#save-btn') - Coordinates —
I.clickXY(400, 300)(last resort)
When a locator fails, the agent tries the next strategy, then a visual click. Locators that worked are saved to experience and preferred on the next run.
Explicit tools: drag and drop, right-click
Section titled “Explicit tools: drag and drop, right-click”Some interactions — dragging an element, opening a context menu with a right-click — need dedicated tools (dragAndDrop, rightClick in src/ai/explicit-tools.ts). They are off by default, so they never grow the Tester’s context for ordinary scenarios. Two gates turn them on:
- Planner gate — during planning, each scenario is checked with the decision model (
provider.oracle(), with the agentic model as fallback). A scenario that needs a drag or a context menu gets the tools armed; the choice is stored in the plan (tools:in the<!-- test -->comment) and survives re-runs. - Pilot gate — mid-run, the Pilot can request the tools for the Tester by including
ENABLE_TOOLS: <names>in its instruction, when the scenario turns out to need an interactionclick()/form()cannot express.
The dragAndDrop() tool takes visual descriptions of what to grab and where to drop it. The vision model locates both points on the screenshot, and the drag runs as a real mouse press between them through the Playwright API — which also covers sliders and canvas drawing, where there is nothing to attach a locator to. When the drop changes nothing, the tool retries the same points with HTML5 drag events on its own; that covers pages whose drag libraries cancel the mouse press, so a real mouse can never start the drag. A modifier key can be held during the drag for copy-drags. The drag is recorded as a plain CodeceptJS I.usePlaywrightTo mouse sequence, so generated tests replay unchanged.
What happens after each action
Section titled “What happens after each action”After every action, Explorbot captures the new page state and compares it with the previous one. The resulting diff tells the agent what changed — the URL, the accessibility tree, or the HTML — so it can confirm the action worked and decide what to do next. The Researcher turns a page into a structured UI map of sections and elements; see Researcher.
See also
Section titled “See also”- Knowledge files — teach Explorbot about your app
- Agent hooks — run code before or after an agent
- Configuration — full configuration reference
- Researcher — how pages become UI maps