Skip to content

FindNode Actions & Commands

Fresh

Actions are performed on nodes matched by queries. Chain multiple actions with semicolons.

Common Actions

ActionDescriptionExample
clickClick matched elementaction: "click"
longClickLong-press elementaction: "longClick"
setText(text)Enter text into fieldaction: "setText(Hello)"
getTextGet element's textaction: "getText"
getIdsGet element IDsaction: "getIds"
getBoundsGet element positionaction: "getBounds"
getNodes(prop)Get nodes with propertyaction: "getNodes(T)"
setChecked(bool)Check/uncheckaction: "setChecked(true)"
ActionDescription
scrollIntoView(query, dir, pages)Scroll until element found
openApp(package)Open app by package name
openAndroidSetting(setting)Open Android settings page
clickForNewWindow(query)Click and wait for new window
sendKey(key)Send keyboard key (Back, Home, Enter)
refreshQueryRe-run query on updated screen

Query Management Actions

ActionDescription
newQuery(query)Start a new query from current context
addQuery(query)Add conditions to current query
waitQuery(query)Wait for element to appear
refresh(query)Refresh with new query

Chaining Actions

Use semicolons to chain multiple actions:

javascript
// Open app, scroll to find element, click it
device.sendAai({
  action: "openApp(com.example.app);scrollIntoView(T:Settings);click"
});

// Get Android version
device.sendAai({
  action: `openAndroidSetting(DEVICE_INFO_SETTINGS);
    click(T:Software information);
    refreshQuery;
    getText('T:Android version&&OY:1')`
});
// Returns: { count: 4, list: [{retval: true},{retval: true},{retval: true},{retval: '16'}] }

Using Action Arrays

For complex sequences, use the actions array:

javascript
device.sendAai({
  actions: [
    "scrollIntoView(T:john)",
    "click",
    "newQuery(TP:textInput)",
    "setText('Hello')",
    "click(OX:2)",
    "sendKey(Back)"
  ]
});

Element-Based Actions

Target specific elements by ID using elements array:

javascript
// Click elements in sequence
device.sendAai({
  elements: [id1, id2, id3],
  action: "forEach(nsClick);sleep(500)"
});

Variables in Queries

Use template literals for dynamic values:

javascript
var input = "Hello World";
device.sendAai({
  query: "TP:textInput",
  actions: [`setText('${input}')`, "click(OX:2)"]
});

Action Return Values

Actions return structured objects:

javascript
// Single action
{ retval: true }              // click success
{ retval: "Button text" }     // getText result
{ count: 5, ids: [...] }      // getIds result

// Chained actions
{ count: 3, list: [
  { retval: true },           // action 1 result
  { retval: true },           // action 2 result
  { retval: "16" }            // action 3 result
]}

Unofficial documentation. Source: sigma-rt.com