-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Predicate Queries Construction Rules
Predicate queries are natively supported by XCTest and enable quick location of elements based on their attribute values.
Follow the rules described in Predicate Format String Syntax article.
WebDriverAgent currently defines the following element attributes:
-
name
- The actual value of element's accessibility identifier or element's label if the first one is not set -
value
- Element's value. It is always of type string (ornil
if the value is not set) and contains the value of the corresponding element. Depending on the element's type this could be: a text or a placeholder text in the text field; a label of a text label;'1'
or'0'
if this is a checkbox or a switch -
label
- Element's label value ornil
if it is not present -
rect
- Element's rectangle as a dictionary with the following keys: x, y, width, heigth -
type
- Type string. All the possible element types are enumerated on this XCTest tutorial page. -
enabled
- Whether the element is enabled or not (1
/0
) -
visible
- Whether the element is displayed or not (1
/0
) -
accessible
- Whether the element is accessible or not (1
/0
) -
accessibilityContainer
- Whether the element is an accessibility container or not (1
/0
)
All these attribute names can be used in predicate queries also with wd
prefixes, for example wdName
.
type == 'XCUIElementTypeButton' AND value BEGINSWITH[c] 'bla' AND visible == 1
- find elements of type XCUIElementTypeButton whose value starts with Bla
/bla
/BLA
and which are visible
type IN {'XCUIElementTypeIcon','XCUIElementTypeImage'} AND visible == 1
- find all visible icons and images
type == 'XCUIElementTypeCell' AND rect.width > 100
- find all cells whose width is greater than 100
type == 'XCUIElementTypeCheckBox' AND (visible == 1 OR enabled == 1)
- find all check boxes, which are visible or enabled