-
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:
- coordinate : [ x, y ] OR { x: #, y : #} Specifies whatever element the OS returns at x, y
- id : string
Matches elements with a givenaccessibilityIdentifer
- text : string
Matches elements who have a given
text
,label
,title
, orplaceholderValue
- text_like : string
As
text
, but diacritical- & case-insensitive substring match. E.g. text_like : 'NåNa' matches 'Banana' - property : "key=value" or { key: string, value: string }
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 overtext
is becausetext
is a 4 part predicate and as such is a bit slower. - property_like : "key=value" or { key: string, value: string }
As
property
but using diacritical- & case-insensitive substring match. Seetext_like
- child : json 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)
- descendent : json
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: