Skip to content

ElementQuery

Use ElementQuery to form a query into the tree of UI elements and then locate one or multiple matching elements.

ElementQuery uses the builder pattern to concatenate criteria, such as searching for descendants, or matching elements only with a certain id.

Construct an instance of this by calling query_descendants. Apply additional criterial on the returned ElementQuery and fetch results by either calling find_first to collect just the first match or find_all to collect all matches for the query.

match_descendants() -> ElementQuery

Applies any subsequent matches to all descendants of the results of the query up to this point.

match_id(id: str) -> ElementQuery

Include only elements in the results where id is equal to the provided id.

match_type_name(type_name: str) -> ElementQuery

Include only elements in the results where type_name is equal to the provided type_name.

match_inherits(type_name: str) -> ElementQuery

Include only elements in the results where type_name or bases is contains to the provided type_name.

match_accessible_role(role: AccessibleRole) -> ElementQuery

Include only elements in the results where accessible_role is equal to the provided role.

find_first() -> Optional[Element]

Runs the query and returns the first result; returns None if no element matches the selected criteria.

find_all() -> List[Element]

Runs the query and returns a list of all matching elements.


© 2026 SixtyFPS GmbH