-
Notifications
You must be signed in to change notification settings - Fork 16
Query Methodology
Chris Fuentes edited this page Mar 24, 2016
·
15 revisions
A Query is composed of a JSON
object that contains specifiers. A specifier
is a key-value pair that helps to specify which element(s) you are interested in finding. Supported specifiers are as follows:
Specifies whatever element the OS returns at x, y
Matches elements with a given `accessibilityIdentifer`
Matches elements who have a given `text`, `label`, `title`, or `placeholderValue`
As `text`, but diacritical- & case-insensitive substring match. E.g. text_like : 'NåNa' matches 'Banana'
Uses predicates to match. E.g. property : 'title=banana' would match an object with the title property set to `banana`.
The reason you'd use this over `text` is because `text` is a 4 part predicate and as such is a bit slower.
As `property` but using diacritical- & case-insensitive substring match. See `text_like`
Specifies that you are looking for a child element of whatever was matched by the current set of specifiers. The value
is its own set of sub-specifiers, using the same possible keys as above. Can only match 1st generation children of the
currently matched element(s)
As `child` but can match descendants at any level.
In the XCUITestServer, queries are evaluated top to bottom in the view hierarchy, starting with the Application element (which is analogous to the root view or window
of an application and contains all other views). A query may specify an element at a particular level or a descendent of that level, but never a parent/ascendent (this is a current limitation of XCUITest and iOS accessibility).
By default, you will always get results in an array form, even if there is only one element.
Examples: