Implementation:A9T9 RPA uiv API
| Knowledge Sources | |
|---|---|
| Domains | Browser_Automation, Desktop_Automation, Scripting_API |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
Concrete tool providing the `uiv.*` JavaScript API surface for authoring and executing browser and desktop automation macros, provided by the Ui.Vision script runner.
Description
The uiv.* API is the in-repo JavaScript scripting API injected into the JS-Interpreter sandbox by `src/modules/script_runner.js`. It is the primary interface for authoring JS script macros. The API covers element finding, image search, OCR, browser and desktop input, navigation, evaluation, and logging.
Key API groups:
- Element finders: `uiv.$` / `uiv.findElement` (first match), `uiv.findElements` / `uiv.$$` (all matches), `uiv.getByRole`, `uiv.getByLabel`, `uiv.getByText`, `uiv.getByPlaceholder`, `uiv.getByTitle`, `uiv.getByAltText`, `uiv.getByTestId`
- Image search: `uiv.findImage`, `uiv.findImages`
- OCR: `uiv.ocr.findText`, `uiv.ocr.findTexts`, `uiv.ocr.read`
- Browser input: `uiv.browser.click`, `uiv.browser.move`, `uiv.page.click`, `uiv.page.fill`, `uiv.page.type`, `uiv.browser.press`
- Desktop input: `uiv.desktop.click`, `uiv.desktop.mouse.click`, `uiv.desktop.type`
- Navigation: `uiv.goto`, `uiv.open`
- Utility: `uiv.run` (bridge to classic commands), `uiv.log`, `uiv.evaluate`, `uiv.shot`, `uiv.offset`, `uiv.exit`, `uiv.getVar`, `uiv.setVar`
The API reference is documented in `uiv-commands.md`.
Usage
The `uiv.*` API is available inside JS script macros executed by the script runner. It is not imported directly — it is injected into the sandbox. Use it when authoring JS macros for browser or desktop automation tasks: element interaction, image-based clicking, OCR text finding, and navigation.
Code Reference
Source Location
- Repository: A9T9/RPA
- File: src/modules/script_runner.js
- Lines: L110-L850 (uiv.* API injection), L245 (findElements), L349 (uiv.$), L400 (findImage), L419 (ocr.findText), L635 (browser.click), L841 (desktop.click), L848 (uiv.log, uiv.run)
- API Reference: uiv-commands.md (L1-L567)
Signature
// Element finding
uiv.$ = function (locator, opts) -> Match // First match
uiv.findElements = function (locator, opts) -> Match[] // All matches
uiv.findElement = uiv.$
uiv.getByRole = function (role, opts) -> Match
uiv.getByLabel = function (text, opts) -> Match
uiv.getByText = function (text, opts) -> Match
// Image search
uiv.findImage = function (image, opts) -> Match
uiv.findImages = function (image, opts) -> Match[]
// OCR
uiv.ocr.findText = function (text, opts) -> Match
uiv.ocr.findTexts = function (text, opts) -> Match[]
// Browser input
uiv.browser.click = function (x, y, opts) -> void
uiv.page.click = function (locator, opts) -> void
uiv.page.fill = function (locator, text, opts) -> void
uiv.browser.press = function (keyCombo) -> void
// Desktop input
uiv.desktop.click = function (...args) -> void
uiv.desktop.type = function (text, opts) -> void
// Navigation
uiv.goto = function (url) -> void
uiv.open = uiv.goto
// Utility
uiv.run = function (cmd, target, value) -> any // Bridge to classic commands
uiv.log = function (text, color) -> void
uiv.evaluate = function (code) -> any
uiv.offset = function (match, dx, dy) -> Point
uiv.getVar = function (name) -> any
uiv.setVar = function (name, value) -> void
uiv.exit = function (reason) -> void
Import
// Not imported — injected into the JS-Interpreter sandbox by script_runner.js.
// Available as global `uiv` inside JS script macros.
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| locator | string | Yes (finders) | DOM locator string (css=, xpath=, id=, name=, ref=, by=) |
| image | string | Yes (findImage) | Stored pattern image filename |
| text | string | Yes (ocr.findText) | Text to find on screen via OCR |
| x, y | number | Yes (browser.click) | Screen/page coordinates |
| cmd, target, value | string | Yes (uiv.run) | Classic command name, target, value |
| opts | object | No | Search/input options (timeout, area, scope, engine, modifiers, etc.) |
Outputs
| Name | Type | Description |
|---|---|---|
| Match | object | Match object with x, y, rect, scope, and element reference |
| Match[] | object[] | Array of Match objects (for plural finders) |
Usage Examples
Element Finding and Clicking
// Find a button by accessible role and click it
const match = uiv.getByRole('button', { name: 'Submit' })
uiv.page.click(match)
// Find all matching elements
const allButtons = uiv.findElements('css=button.action')
// Fill a form field
uiv.page.fill('name=email', 'user@example.com')
Image Search and Desktop Click
// Find an image on screen and click it (desktop)
const match = uiv.findImage('login_button_dpi_96.png')
uiv.desktop.click(match.x, match.y)
OCR Text Finding
// Find text on screen via OCR and click it
const match = uiv.ocr.findText('Sign In', { engine: 'builtin' })
uiv.browser.click(match.x, match.y)
// Click with an offset from the matched text
const point = uiv.offset(match, 50, 10)
uiv.browser.click(point.x, point.y)
Bridge to Classic Commands
// Run a classic command from within a JS script
uiv.run('waitForElementPresent', 'xpath=//div[@id="result"]', '10000')
uiv.run('store', 'Hello', 'myVar')
const val = uiv.getVar('myVar')
uiv.log('Stored value: ' + val)
Related Pages
Implements Principle
- Principle:A9T9_RPA_Script_Authoring
- Principle:A9T9_RPA_API_Call_Resolution
- Principle:A9T9_RPA_Command_Dispatch