-
Notifications
You must be signed in to change notification settings - Fork 5
Igor Query Language
An Igor query is a pattern that identifies a set of views in an iOS window.
The easiest way to understand the Igor query syntax is to start with its smallest pieces, then learn how the pieces can be combined and what the combinations mean.
The smallest unit of an Igor query is the simple pattern. A Simple Pattern assesses an individual view against a single criterion. A view that satisfies the criterion is said to match the pattern.
Examples of simple patterns:
-
*— the universal pattern that matches any view. -
UIView— a class pattern that assesses a view based on its class. -
[accessibilityLabel='settings button']— a predicate pattern that evaluates a view against a predicate. -
#settings— an identifier pattern that assesses a view based on the value of an identifying property. -
:first-child— a position pattern that assesses a view based on its relationship to its immediate neighbors in the containment hierarchy.
An Instance Pattern is a sequence of simple patterns with no intervening punctuation or whitespace. A view matches an instance pattern if it matches each simple pattern in the instance pattern.
Examples of instance patterns:
UIControl*[accessibilityLabel='settings button']UITextField:first-childUIButton[highlighted=TRUE]:nth-child(2)
A Relationship Pattern is a sequence of instance patterns separated by combinators and grouped by parentheses. A combinator is punctuation that describes a relationship between two instance patterns.
Examples of relationship patterns:
-
#settings * UIButton:first-child— three instance patterns separated by descendant combinators (whitespace). -
[accessibilityLabel='books'] > UILabel:first-child— two instance patterns separated by a child combinator. -
#publisher (MYPublisherView [text='New York']) [accessibilityLabel='Phone Number']— the parentheses form a branch pattern.
An Igor Query is a relationship pattern. One of the top-level patterns (i.e. the patterns not in a branch pattern) can be marked as the subject of the query.
-
#publisher $MyPublisherView [text='address']— the dollar sign marks the middle instance pattern as the relationship pattern's subject.