FindNode Query Syntax
FreshQueries follow JSON format with three sections: Template (TP), Basic Query (BQ), and Expanded Query (EQ).
Query Structure
javascript
device.sendAai({
query: "TP:more", // Template
query: "T:Hello&&C:Button", // Basic query with AND
action: "click" // Action to perform
});Multiple conditions use && (AND) or || (OR) separators.
Basic Query
An empty query returns most nodes on the screen:
javascript
var output = device.sendAai({});
// Returns: { count: 89, ids: ["80006cbe","7440","7bc2",...] }Default template is TP:more with action getIds.
Basic Query Properties
| Code | Property | Example |
|---|---|---|
| P | Package name | P:com.example.myapp |
| C | Class name | C:Button |
| R | Resource ID | R:button5 |
| T | Text content | T:Submit |
| D | Description | D:Close button |
| BP | Boolean properties | BP:clickable, BP:editable |
| IT | Input type | IT:>10000 |
| CC | Child count | CC:!=0, CC:>0 |
| BI | Bounds | BI:[0,0][540,960] |
| HT | Hint text | HT:Enter your name |
Filtering Examples
javascript
// Nodes with children
device.sendAai({ query: "CC:!=0" });
// Custom inputType values
device.sendAai({ query: "IT:>10000" });
// Combined conditions
device.sendAai({ query: "CC:!=0&&IT:>10000" });
// Text matching (case-insensitive)
device.sendAai({ query: "T:ci:hello" });
// Wildcard text matching
device.sendAai({ query: "T:*REAL, \nSANTA CLARA*" });Expanded Query Options
| Code | Feature | Description |
|---|---|---|
| IX | Indexing | Select nth match: IX:0 (first), IX:-1 (last) |
| OX/OY | Offset | Navigate to adjacent nodes |
| VG | ViewGroup | Traverse parent/child relationships |
| TX/TY | Intersection | Detect overlapping elements |
| RN | Reduction | Reduce node set |
| ST | Sorting | Sort results |
Text Input Examples
javascript
// Enter text in last editable field
device.sendAai({ query: "BP:editable&&IX:-1", action: "setText(Hello)" });
// Find field by hint text
device.sendAai({ query: "HT:Input text here", action: "setText(Hello)" });Scrolling
javascript
// Scroll down 2 pages looking for "john" (case-insensitive), then click
device.sendAai({
actions: ["scrollIntoView(T:ci:john, down, 2);click"]
});