alibaba/page-agent · error · Error
No interactive element found at index ${index}
Error message
No interactive element found at index ${index} What it means
This error is thrown by getElementByIndex when the selector map produced by updateTree() has no interactive element entry for the given index. Indexes only exist for elements the DOM extraction marked as interactive during the last indexing pass, so an unknown index means the caller is using a stale or invented number. It protects against silently acting on the wrong element.
Source
Thrown at packages/page-controller/src/actions.ts:29
isHTMLElement,
isInputElement,
isSelectElement,
isTextAreaElement,
movePointerToElement,
waitFor,
} from './utils'
/**
* Get the HTMLElement by index from a selectorMap.
* @private Internal method, subject to change at any time.
*/
export function getElementByIndex(
selectorMap: Map<number, InteractiveElementDomNode>,
index: number
): HTMLElement {
const interactiveNode = selectorMap.get(index)
if (!interactiveNode) {
throw new Error(`No interactive element found at index ${index}`)
}
const element = interactiveNode.ref
if (!element) {
throw new Error(`Element at index ${index} does not have a reference`)
}
if (!isHTMLElement(element)) {
throw new Error(`Element at index ${index} is not an HTMLElement`)
}
return element
}
let lastClickedElement: HTMLElement | null = null
function blurLastClickedElement() {
if (lastClickedElement) {View on GitHub (pinned to d02db1ee7c)
Solutions
- Re-run updateTree() and act on indexes from the fresh getSimplifiedHTML() output
- Verify the index exists before acting: controller.element?.(index) or check the selector map via getPageInfo()
- Make the agent retry with a fresh observation when an action fails with this error
- Log the current simplified HTML alongside the failing index to spot staleness or hallucination
Example fix
// before await controller.clickElement(42) // index no longer exists // after await controller.updateTree() const html = await controller.getSimplifiedHTML() // pick an index present in html, then: await controller.clickElement(42)
Defensive patterns
Strategy: validation
Validate before calling
const info = await controller.getPageInfo() // or getSimplifiedHTML(); confirm the index appears before acting
Try / catch
try { await controller.clickElement(i) } catch (e) { if (/No interactive element found at index/.test(String(e))) { await controller.updateTree(); /* re-pick index */ } else throw e } Prevention
- Never reuse indexes across updateTree() generations
- Derive indexes only from the latest getSimplifiedHTML() output
- Retry with a fresh observation when index errors occur in agent loops
When it happens
Trigger: Calling clickElement/inputText/selectOption with an index not present in the current selectorMap; using indexes from a previous updateTree() run after the page changed; passing a raw DOM node index instead of an interactive-element index; hallucinated indexes from the LLM.
Common situations: Agent loop re-indexes between steps but reuses indexes from the older observation; page re-rendered (React/Vue) between observation and action; index parsing off-by-one; LLM output references an index that no longer exists.
Related errors
- DOM tree not indexed yet. Can not perform actions on element
- Element at index ${index} does not have a reference
- Element at index ${index} is not an HTMLElement
- Element is not an input, textarea, or contenteditable
- Element is not a select element
AI-assisted analysis of alibaba/page-agent@d02db1ee7c (2026-08-28).
Data as JSON: /api/errors/acb20da4221ec59f.
Report an issue: GitHub.