qt_find_element
Locate UI elements in a live Qt app by matching type, text, object name, or properties. Returns element IDs for immediate use in automation commands.
Instructions
Find UI elements matching a query in a session.
Query fields (all AND-ed): type (exact C++ class name),
type_inherits (superclass chain — C++ classes only; custom QML
components are generated classes like X_QMLTYPE_8 and do NOT match
a QML type name), text / text_contains (display text, CJK
supported), object_name, window_title /
window_title_contains, properties (all key-value pairs must
match), ancestor_id / window_id (scope limits), depth
("exact" = direct children, "shallow" = 2 levels, integer = that many,
"deep"/omitted = whole tree), limit (max matches). include_hidden
is a field INSIDE the query dict (default false) — hidden elements
are only matched when it is true.
Example: {"text_contains": "OK", "type_inherits": "QPushButton", "depth": "shallow"} or {"object_name": "searchBox", "limit": 5}.
Result: {"ok": true, "count": N, "elements": [{id, className, objectName, ...}]}; when nothing matches: {"ok": false, "message": "No matching element found"} — adjust the query or set include_hidden: true. No prior snapshot is needed; this call rebuilds the element map itself.
ID LIFECYCLE: the rebuild invalidates EVERY element_id/window_id from previous snapshots/finds. Use the returned ids immediately — if an operation reports "Element not found: id=N", the id is stale or the element was destroyed: re-run qt_find_element (or a snapshot) and retry with the fresh id; never reuse old ids.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| session_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |