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
  • output
  • Output Namespaces

Was this helpful?

Edit on GitHub
  1. Advanced
  2. JavaScript

Outputs

Though entirely optional, normally one would run a JavaScript code in order to produce a result to be used with other commands.

output

The whole flow shares a single global output JavaScript object that can be modified to include results of a flow:

// myScript.js
output.result = 'Hello World'

Where it can later be accessed either in the flow itself or in other scripts:

- runScript: myScript.js
- inputText: ${output.result}

Note that in the example above, result is just an arbitrary name. It could be anything.

Output Namespaces

Since output field is global, several scripts might clash with each other. Consider this example:

// mySecondScript.js
output.result = 'Bye World'

The following flow will then print Bye World, overriding Hello World result from myScript.js

- runScript: myScript.js
- runScript: mySecondScript.js
- inputText: ${output.result}   # inputs 'Bye World'

To avoid such conflicts, consider using namespaces for your outputs:

// myScript.js
output.myScript = {
    result: 'Hello World'
}
// mySecondScript.js
output.mySecondScript = {
    result: 'Bye World'
}

Where a flow can then be explicit about which output it wants to use:

- runScript: myScript.js
- runScript: mySecondScript.js
- inputText: ${output.myScript.result}   # inputs 'Hello World'
- inputText: ${output.mySecondScript.result}   # inputs 'Bye World'

Note that you have full control over how to structure the outputs and are free to keep them as sophisticated or simple as you want. By the end of the day, output is just a JavaScript object.

PreviousRun JavaScriptNextLogging

Last updated 2 years ago

Was this helpful?