Check the clipboard content
Validate OS clipboard by pasting into system search (Spotlight/Android) and asserting expected text with Maestro.
The workflow
1. Reusable validation Flow
# check_clipboard.yaml
# Requirements: iOS 18 Simulator / Android API 34 Emulator
# Required Env: EXPECTED_CONTENTS (The string you expect to be in the clipboard)
appId: ${APP_ID}
---
# Step 1: Minimize the app. This is like the user pressing the Home button.
- pressKey: Home
# Step 2: Find a place to "write" the clipboard contents.
# Here, the platform's native search bar is used.
- runFlow:
when:
platform: Android
commands:
- tapOn: Search # Targets the Home screen widget
- tapOn:
id: input # Focus search input
- longPressOn:
id: input
- tapOn: Paste
- runFlow:
when:
platform: iOS
commands:
- pressKey: Home # Second tap ensures we are on the first home screen page
- tapOn: Search # Targets the iOS search "pill"
- longPressOn:
id: SpotlightSearchField
- tapOn: Paste
# Step 3: Assertion
# Check if the OS-level search field now contains the expected text
- assertVisible: ${EXPECTED_CONTENTS}
# Step 4: Cleanup
# Explicitly clear the search field and set the clipboard to a known dummy value to ensure test isolation
- runFlow:
when:
platform: Android
commands:
- tapOn: Clear search box
- inputText: Hello World
- longPressOn:
id: input
- tapOn: Select all
- tapOn: Cut
- runFlow:
when:
platform: iOS
commands:
- tapOn: Clear text
- inputText: Hello World
- longPressOn:
id: SpotlightSearchField
- tapOn: Select All
- tapOn: Cut
# Step 5: Return to App
- launchApp:
stopApp: false # Brings the app back to the foreground without restarting it2. Implementation
Related content
Last updated