Test Step Selectors
A selector is an identifier used to interact with a view in your app's component hierarchy.
All selectors are optional, but at least one must be used if the test step command requires it. Many test step commands support selectors including:
All Options
Text Selector
Finds a view using text (or accessibility text). For example, to assert that an element rendering "Press Here" is visible:
ID Selector
Finds a view using an ID. For example, to assert that an element with ID "login_submit_button" is visible:
Optional modifier
If you wish to test to continue even if the view or element cannot be founder, then set optional
to true. This modifier defaults to false.
Picking a single view from multiple matches
If the view component you are selecting has multiple matches, you can use the index
option to choose a single view. For example, to tap the first card from a list of many cards:
Point Selector
The point
selector uses X/Y coordinates to select a position on the device viewport. Provide percentages for a relative coordinate or integers to select a exact pixel.
For example, to tap on the exact center of the screen:
For example, to swipe from the text "some text" to the pixel in the top-left corner:
Width and Height Selector
The width
and height
selectors will find elements with the given width and/or height in pixels.
Optionally, provide the tolerance
parameter to allow a pixel range.
For example, to copy text from the first element with a width and height between 290px and 310px:
Checked Selector
The checked
selector will find elements that are checked.
For example, with a checkbox:
Focused Selector
The focused
selector will find elements that are focused. This can be useful for asserting that text inputs are correctly focused for input.
For example, with a button:
Selected Selector
The selected
selector will find elements that are selected.
For example, with a radio button:
Enabled Selector
The enabled
selector will find elements that are enabled. Typically, almost all elements are enabled. However, this can be useful for asserting that particular elements are disabled.
For example, with a button:
Relative Position Selectors
Additionally, you may use a relative selector to find an element spatially or hierarchically connected to another element. This is especially useful when the element you wish to interact with is missing an ID.
Contains Child Selector
Contains Descendants Selector
Above Selector
Below Selector
LeftOf Selector
RightOf Selector
Last updated