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
  • Basic flow
  • Text Input
  • Accessibility info
  • System menus / dialogs
  • System controls
  • Switching between different apps
  • Known issues:

Was this helpful?

Edit on GitHub
  1. Platform Support

iOS - SwiftUI

PreviousiOS - UIKitNextReact Native

Last updated 3 months ago

Was this helpful?

Maestro fully supports iOS apps that use SwiftUI. In addition to iOS UIKit apps it is possible to write maestro flows for the apps that are written in SwiftUI. For showcasing the capabilities of maestro two open-source apps were picked - from WWDC22 and that demonstrates different SwiftUI components in a storybook manner.

Basic flow

index: 0 can be omitted and the first step of the flow looks like that:

- tapOn:
    text: "New Orders"

Text Input

// First typing on the element that has a prewritten placeholder text:
- tapOn:
    text: "New Donut"
    index: 1

// Erasing the text completely
- eraseText

// input new contents for the TextField
- inputText: "Test Donut"

There is a better way to focus on a TextField rather than watching on its contents - accessibility id / label, which is explained in the next section.

Accessibility info

The best practice to write reliable flows with maestro for SwiftUI is to assign accessibilityIdentifier or accessibilityLabel for UI element that needs to be accessed.

Here is the code modification that needed to be done for the Food Truck to make tapOn work with id:

NavigationLink(value: Panel.donutEditor) {
	Label("Donut Editor", systemImage: "slider.horizontal.3")
}.accessibilityIdentifier("donut_editor")

Corresponding tap command on maestro side would now look like that:

- tapOn:
    id: "donut_editor"

System menus / dialogs

System controls

Switching between different apps

- tapOn:
    id: "breadcrumb"

breadcrumb is an accessibility id of the “Back to SwiftUI app” button on the screenshot below, which was also found with a help of maestro studio

Known issues:

  • Hierarchy for some elements is not returned (i.e. WheelPickerStyle)

  • When Toggle is initialized with text, its accessibility element is a union of a text and toggle

  • Sometimes only one of accessibilityLabel / accessibilityIdentifier (i.e. Link)

  • Sometimes List / Group elements are not assigning accessibility ids / labels correctly (i.e SectionView { Group { Menu } })

First lets start with some basic flow for FoodTruck app. Almost every SwiftUI native element is identifiable with maestro studio. For instance here is how the first step of was generated:

All the other steps in this flow were generated the same way, following examples provided by maestro studio. The itself navigates to order details screen, marks that an order is completed and finally asserts that the order is not in the list anymore, which can be considered as real-world use-case scenario.

of a flow that relies on the text input.

Full flow can be found . maestro translates accessibilityIdentifier to id while accessibilityLabel is translated to text. When an element has both some text content and accessibilityLabel assigned the latter will be picked as a value for text by maestro framework.

demonstrates how to interact with different types of native popups / dialogs / context menus etc. To simplify an access to the elements accessibilityIdentifier was used again, whenever possible.

demonstrates how to interact with native SwiftUI controls like Toggle, Picker, Segmented Picker. The best practice here is to give unique accessibilityIdentifier values to individual elements that represent some value in a list.

Switching between different apps during the same flow is also supported by maestro. opens url in Safari and then returns to the main app (SwiftUI-Kit) that was previously launched.

first_flow.yaml
flow
Here is an example
here
The following flow
The following flow
The following flow
https://github.com/mobile-dev-inc/maestro-docs/blob/main/platform-support/broken-reference/README.md
Food Truck app
SwiftUI Kit app