Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:A9T9 RPA Element Identification

From Leeroopedia
Knowledge Sources
Domains Browser_Automation, DOM_Resolution
Last Updated 2026-10-22 00:00 GMT

Overview

Mechanism for resolving stored locator strings back to live DOM elements during macro playback using prefix-based lookup dispatch.

Description

Element Identification is the inverse of element recording: given a locator string stored in the command table, resolve it to the actual DOM element in the live page during playback. A locator string encodes both the lookup method and the query value, separated by a prefix (e.g. `id=submit`, `css=.btn-primary`, `xpath=//div[@id="x"]`).

The resolver must:

  • Parse the prefix to determine the lookup method
  • Dispatch to the appropriate DOM query API (`getElementById`, `querySelector`, `evaluate` for XPath, etc.)
  • Optionally wait for the element to become visible (for robustness against timing-dependent rendering)
  • Return `undefined` if the element is not found, so the player can report an error

Usage

Use this principle when designing a macro playback engine that needs to locate elements by stored locators. It applies to any Selenium IDE-style command table replay system.

Theoretical Basis

Locator resolution is a dispatch table pattern:

resolve(locator)=dispatch(prefix(locator),value(locator))

Where the prefix maps to a DOM query function:

Pseudo-code Logic:

# Abstract resolution algorithm (NOT real implementation)
def resolve(locator, wait_for_visible=False):
    if locator.startswith('/'):
        return xpath_query(locator)
    prefix, value = locator.split('=', 1)
    if prefix == 'id':       return document.get_element_by_id(value)
    if prefix == 'name':     return document.get_elements_by_name(value)[0]
    if prefix == 'css':      return document.query_selector(value)
    if prefix == 'xpath':    return xpath_query(value)
    if prefix == 'link':     return find_link_by_text(value)
    if wait_for_visible:
        return wait_until_visible(resolve(locator))

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment