tapOn
Tap on UI elements by text, ID, or coordinates with optional repeat and delay.
The tapOn command performs a tap gesture on a UI element or a specific coordinate on the screen. It is the most common interaction command in Maestro.
Perform a long press
Use the longPressOn command to perform a long press. It accepts the same selectors and parameters as tapOn.
Parameters
You can specify the target element using a shorthand text selector or a map containing a selector and optional interaction parameters.
selector
String or Map
Required. The element to tap. Use a string for a shorthand text selector (e.g. "My Text"). For other selectors or to add parameters, use a map. See the Selectors documentation for a full list.
point
String
A specific coordinate to tap on the screen or within a selected element. Use relative percentages (e.g. "50%,50%") or absolute pixel values (e.g. "100,200").
repeat
Integer
The number of times to repeat the tap.
delay
Integer
The delay in milliseconds between each tap when using repeat. Defaults to 100.
retryTapIfNoChange
Boolean
If true, Maestro retries the tap if the UI hierarchy does not change after the initial tap. This is useful for handling early taps before the UI is fully responsive.
waitToSettleTimeoutMs
Integer
The maximum time in milliseconds that Maestro waits for the screen to settle before executing the next command. This is a best-effort timeout; Maestro does not interrupt core operations to honor it.
Usage examples
The following examples demonstrate how to use the tapOn and longPressOn commands.
Tap an element by text or ID
The fastest way to interact with your app is via visible text or technical identifiers. This example shows the shorthand for tapping an element by its visible text.
- tapOn: "My text"This example uses the id selector to tap an element.
Repeat a tap
If you need to tap the same element several times in a row, use repeat. This option is useful, for example, when you need to increase the value of a counter.
If you need to wait for the animation to finish before executing the next tap, use delay. This example taps the button five times with a 200 ms delay between each tap.
Retry a tap if the UI is unresponsive
If a tap is ignored because the target was not ready yet or an animation is still playing, use retryTapIfNoChange. This example retries the tap if the UI does not change after the first attempt.
Tap a specific coordinate
While element selectors are preferred, you can target specific points on the screen. This example taps the center of the screen.
This example taps an absolute coordinate on the screen.
Prefer using element selectors like id or text over coordinates. Tapping by coordinate can make tests brittle and device-dependent.
Tap a coordinate within an element
This example finds an element containing specific text and then taps a point near the end of that element.
Full flow example
This example demonstrates a sequence of commands to add a new contact.
Related content
Check the related commands:
Or, learn about the different ways to identify elements using Selectors.
Last updated