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 SmartLocator

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

Overview

Concrete CDP-based element locator that resolves accessibility tree UIDs to DOM elements and performs interactions (click, fill, hover, boundingBox, getEditorValue) via Chrome DevTools Protocol.

Description

The SmartLocator class implements the `Locator` interface for focus mode automation. It is constructed with a `tabId`, a `TextSnapshotNode`, and a `backendDOMNodeId`. It creates a `CdpCommander` internally and uses `DOM.resolveNode` to convert the backend node ID to a remote object, then `Runtime.callFunctionOn` to execute interaction functions (fill, click, hover) in the page context. It supports Monaco Editor value extraction via `getEditorValue`. The `boundingBox` method attaches the debugger if needed and retrieves element coordinates for visual automation.

Usage

  • Click element: `await new SmartLocator(tabId, node, backendId).click()`
  • Fill input: `await locator.fill("hello@example.com")`
  • Get Monaco editor value: `const value = await locator.getEditorValue()`
  • Get bounding box: `const box = await locator.boundingBox()`

Code Reference

Source Location

  • Repository: AIPex
  • File: packages/browser-runtime/src/automation/smart-locator.ts
  • Lines: L13-100 (class definition + core methods), L1073 (SmartLocator export)

Signature

export class SmartLocator implements Locator {
  constructor(tabId: number, node: TextSnapshotNode, backendDOMNodeId: number)

  async fill(value: string): Promise<void>
  async click(options?: { count?: number }): Promise<void>
  async hover(): Promise<void>
  async boundingBox(): Promise<{ x: number; y: number; width: number; height: number } | null>
  async getEditorValue(): Promise<string | null>
}

Import

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

I/O Contract

Inputs

Name Type Required Description
tabId number Yes Target browser tab ID
node TextSnapshotNode Yes Accessibility tree node for the element
backendDOMNodeId number Yes CDP backend DOM node ID
value string Yes (fill) Text to type into the element
options.count number No (click) Click count (default 1)

Outputs

Name Type Description
fill/click/hover void Throws on failure
boundingBox null Element coordinates or null
getEditorValue null Monaco/standard editor value or null

Usage Examples

Click and Fill via CDP

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

const node = getNodeByUid(tabId, "abc123");
if (node) {
  const locator = new SmartLocator(tabId, node, backendDOMNodeId);
  await locator.click();          // single click
  await locator.fill("hello@world.com"); // type text
}

Get Monaco Editor Value

const locator = new SmartLocator(tabId, editorNode, editorBackendId);
const code = await locator.getEditorValue();
console.log(code); // Monaco editor content

Related Pages

Implements Principle

Requires Environment

Page Connections

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