State Selectors
Select elements by state: enabled, checked, focused, or selected properties.
State Selectors allow you to filter UI elements based on their current functional or interactive status. These are primarily used to verify that an element is ready for interaction, has been correctly updated by a previous action, or to find a specific element among several identical ones (e.g., finding the selected tab in a navigation bar).
Overview
All state selectors accept a boolean value (true or false).
Selector
Description
enabled
Matches elements based on whether they are currently interactive or "grayed out."
checked
Matches elements based on their toggle state (Checkboxes, Radio Buttons, Switches).
focused
Matches the element that currently has keyboard input focus.
selected
Matches elements currently marked as selected (often used for Tabs or Segmented Controls).
enabled
The enabled selector is essential for ensuring that an app’s logic is functioning correctly. For example, a "Submit" button should remain disabled (enabled: false) until all required fields are filled.
# Assert that the login button is disabled initially
- assertVisible:
id: login_button
enabled: false
# Tap the button once it becomes active
- tapOn:
id: login_button
enabled: truechecked
This selector is specifically for elements that hold a binary state, such as checkboxes, radio buttons, and switches.
focused
The focused selector identifies the element that is currently active for text input. This is useful for verifying that tapOn correctly placed the cursor in the right field or that an app automatically focuses the first input field on a form.
selected
While similar to checked, selected is typically used for navigation elements like tabs, segmented controls, or specific items in a list that have been highlighted.
Last updated