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

Implementation:AIPexStudio AIPex DomLocator

From Leeroopedia
Knowledge Sources
Domains Browser_Automation, DOM
Last Updated 2026-10-24 12:00 GMT

Overview

Concrete DOM-based element locator for background mode that performs element interactions via chrome.scripting.executeScript without requiring debugger attachment.

Description

The DomLocator class implements element interactions for background mode automation. Instead of using CDP, it injects a function via `chrome.scripting.executeScript` that locates elements by a data-UID attribute (injected during DOM snapshot collection) and performs the requested action (click, fill, hover, bounding-box, value, editor-value). All methods return a `DomActionResponse<T>` with `success`, optional `error`, and optional `data`, providing a uniform error contract without throwing.

Usage

  • Click: `const result = await new DomLocator(tabId).click(uid)`
  • Fill: `await new DomLocator(tabId).fill(uid, { value: "text" })`
  • Get value: `const { data } = await new DomLocator(tabId).value(uid)`

Code Reference

Source Location

  • Repository: AIPex
  • File: packages/browser-runtime/src/automation/dom-locator.ts
  • Lines: L47-80 (class methods), L76-110+ (executeInPage), L1-45 (types)

Signature

export class DomLocator {
  constructor(private tabId: number)

  async click(uid: string, options?: ClickOptions): Promise<DomActionResponse>
  async fill(uid: string, options: FillOptions): Promise<DomActionResponse>
  async hover(uid: string, options?: HoverOptions): Promise<DomActionResponse>
  async boundingBox(uid: string): Promise<DomActionResponse<BoundingBox | null>>
  async value(uid: string): Promise<DomActionResponse<string | null>>
  async editorValue(uid: string): Promise<DomActionResponse<string | null>>
}

interface DomActionResponse<T = void> {
  success: boolean;
  error?: string;
  data?: T;
}

interface FillOptions {
  value: string;
  commit?: boolean;
  highlight?: boolean;
  scroll?: boolean;
}

Import

import { DomLocator } from "@aipexstudio/browser-runtime";

I/O Contract

Inputs

Name Type Required Description
uid string Yes Element UID from DOM snapshot
options.value string Yes (fill) Text to type
options FillOptions\|HoverOptions No Action options (highlight, scroll, commit)

Outputs

Name Type Description
returns DomActionResponse<T> { success, error?, data? }

Usage Examples

Background Mode Click

import { DomLocator } from "@aipexstudio/browser-runtime";

const locator = new DomLocator(tabId);
const result = await locator.click("abc123");
if (!result.success) {
  console.error("Click failed:", result.error);
}

Fill Input Field

const locator = new DomLocator(tabId);
const result = await locator.fill("uid_input_1", {
  value: "user@example.com",
  commit: true,
});

Related Pages

Implements Principle

Requires Environment

Page Connections

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