LogoLogo
🚀 Run Maestro tests in the cloud →
  • Home
  • Star us on GitHub
  • Getting Started
    • What is Maestro?
    • Installing Maestro
      • macOS
      • Windows
      • Linux
    • Build and Install your App
      • Android
      • iOS
    • Run a Sample Flow
    • Writing Your First Flow
    • Maestro Studio
    • Running Flows on CI
  • Cloud
    • Run Maestro tests in the cloud
    • Cloud Quickstart
    • CI Integration
      • GitHub Actions
        • Maestro GitHub Action for Android
        • Maestro GitHub Action for iOS
        • Maestro GitHub Action for Flutter
      • Bitrise
      • Bitbucket Pipelines
      • CircleCI
      • Integration with any CI platform
    • Pull Request Integration
    • Cloud Reference
      • Build your app for the cloud
      • Configuring OS Version
      • Configuring device locale
      • Device timezones
      • Email Notifications
      • Slack Notifications
      • Webhook Integration
      • Managing Secrets
      • Limits
      • Reusing App Binary
      • IP Allowlist
      • System Status
  • Platform Support
    • Supported Platforms
    • Android - Views
    • Android - Jetpack Compose
    • iOS - UIKit
    • iOS - SwiftUI
    • React Native
    • Flutter
    • Web Views
    • Web (Desktop Browser)
  • Examples
    • Android contacts flow automation
    • Facebook signup flow automation
    • Advanced: Wikipedia Android
    • Page Object Model
  • CLI
    • Cloud
    • Test Suites & Reports
    • Tags
    • Record Your Flow
    • Continuous Mode
    • View Hierarchy
    • Start Device
  • API Reference
    • Commands
      • addMedia
      • assertVisible
      • assertNotVisible
      • assertTrue
      • assertWithAI
      • assertNoDefectsWithAi
      • back
      • clearKeychain
      • clearState
      • copyTextFrom
      • evalScript
      • eraseText
      • extendedWaitUntil
      • extractTextWithAI
      • hideKeyboard
      • inputText
      • killApp
      • launchApp
      • openLink
      • pressKey
      • pasteText
      • repeat
      • retry
      • runFlow
      • runScript
      • scroll
      • scrollUntilVisible
      • setAirplaneMode
      • setLocation
      • startRecording
      • stopApp
      • stopRecording
      • swipe
      • takeScreenshot
      • toggleAirplaneMode
      • tapOn
      • doubleTapOn
      • longPressOn
      • travel
      • waitForAnimationToEnd
    • Common command arguments
    • Selectors
    • Configuration
      • Workspace configuration
      • Flow configuration
      • AI configuration
  • Advanced
    • Nested Flows
    • Wait
    • Loops
    • Conditions
    • Parameters & Constants
    • JavaScript
      • Run JavaScript
      • Outputs
      • Logging
      • Access element text
      • Make HTTP requests
      • GraalJS support
      • JavaScript announcement blog
    • Specify a Device
    • Configure Permissions
    • Detect Maestro in your app
    • Configure Maestro driver timeout
    • onFlowStart / onFlowComplete hooks
    • Test in different locales
    • Structuring your test suite
  • Troubleshooting
    • Known Issues
    • Frequently Asked Questions
    • Bug Report
    • Rollback Maestro
    • Debug Output
    • HOWTOs
      • Arrange your repository for Maestro tests
      • scrollUntilVisible for fragments
  • Community
    • Contributions
    • Articles & Tutorials
    • Case Studies
    • Resources
Powered by GitBook

Read to wire into CI or scale up your testing?

  • Run Maestro tests in the cloud →
On this page
  • Repeat taps
  • retryTapIfNoChange
  • Control wait time
  • Tapping on a specific point on the screen
  • Tapping on a specific point within another element
  • Long press
  • Long press on a specific point within another element
  • Example

Was this helpful?

Edit on GitHub
  1. API Reference
  2. Commands

tapOn

PrevioustoggleAirplaneModeNextdoubleTapOn

Last updated 10 months ago

Was this helpful?

In order to tap on a view with the text "My text" you can use the shorthand selector for text like this:

- tapOn: "My text"

You can also use other selectors such as id:

- tapOn:
    id: "id" # or any other selector

For a full list of selectors, please refer to the page.

Repeat taps

In some cases it is desirable to repeat taps. To achieve that, the following is possible:

- tapOn:
    text: "Button"
    repeat: 3
    delay: 500 # (optional) Delay between taps. Default 100ms

- tapOn:
    id: "someId"
    repeat: 3

retryTapIfNoChange

Sometimes, tapOn will try to tap again if it doesn't detect a hierarchy change. To fix such cases, use retryTapIfNoChange. For example:

- tapOn:
    id: "someId"
    retryTapIfNoChange: false

In this example, the tapOn will never try to tap again.

Control wait time

Maestro usually waits for the screen to settle before moving to the next command, however that is not always desirable.

If your app or screen has the following:

  • Moving elements like a countdown timer

  • Non-blocking animations that are part of the UI

Then, you can use waitToSettleTimeoutMs to limit the time Maestro waits for things to settle

- tapOn:
    text: "Button"
    waitToSettleTimeoutMs: 500 # ms

Note: This will be a best effort timeout. Maestro will not interrupt core operations to honor the timeout.

Tapping on a specific point on the screen

Whenever possible, prefer tapping on view id or text instead of coordinates as this might make your tests dependent on a specific type of a device

You can specify a relative position on the screen using:

- tapOn:
    point: 0%,0%        # top-left corner
- tapOn:
    point: 100%,100%    # bottom-right corner
- tapOn:
    point: 50%,50%      # middle of the screen

You can also specify absolute coordinates on the screen to tap on:

- tapOn:
    point: 100,200    # This command will tap on point x:100 y:200 on the screen (in pixels)

Tapping on a specific point within another element

If you wish to tap on a point on screen inside another element you can do the following:

- tapOn:
    text: "A text with a hyperlink"
    point: "90%,50%"

This will find an element with text "A text with a hyperlink" and tapOn towards the end of the sentence where "hyperlink" is located.

Long press

To long press on a view or a point, use the same exact properties but with a longPressOn command:

- longPressOn: Text
- longPressOn:
    id: view_id
- longPressOn:
    point: 50%,50%

Long press on a specific point within another element

If you wish to long press on a point on screen inside another element you can do the following:

- longPressOn:
    text: "A text with a hyperlink"
    point: "90%,50%"

This will find an element with text "A text with a hyperlink" and longPressOn towards the end of the sentence where "hyperlink" is located.

Example

appId: com.android.contacts
---
- launchApp
- tapOn:
    id: .*floating_action_button.* #regex
- inputText: "John"
- tapOn: "Last Name"
- inputText: "Snow"
- tapOn: .*Save.*
Selectors