Skip to content

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.

Agents read each page three ways at once:

SourceWhat it givesUsed for
ARIA snapshotRoles, labels, states, hierarchyUnderstanding structure, building locators
HTMLClasses, IDs, data attributes, form fieldsPrecise locators, reading field values
ScreenshotLayout, colors, icons, coordinatesVisual 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.

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:

explorbot.config.js
html: {
combined: {
include: ['*'],
exclude: ['script', 'style', 'svg', '.cookie-banner', '.analytics-tracker'],
},
}

Three snapshots exist, each configurable:

SnapshotPurposeConfig key
combinedMain HTML for agentshtml.combined
minimalInteractive elements onlyhtml.minimal
textText content onlyhtml.text

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.

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.

  1. Short ARIA or text — I.click({ role: 'button', text: 'Save' }) or I.click('Save') when it is unique
  2. Text with a container — I.click('Save', '.modal') — simplest and preferred when a container is known
  3. ARIA with a container — I.click({ role: 'button', text: 'Save' }, '.modal') — for semantic disambiguation
  4. CSS or XPath — I.click('#save-btn')
  5. 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 interaction click()/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.

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.