Skip to content

setClipboard ​

Set the device clipboard to a specified text value.

Partial support in Astra Scout

Android only. On iOS (Simulator and iOS device) the command fails. To get text into an iOS field, use inputText, or copyTextFrom followed by pasteText.

The setClipboard command puts a text string on Astra Scout's clipboard (the temporary store used for copy and paste). Use it when you want to choose the clipboard content yourself. copyTextFrom, by contrast, copies text from an element on the screen.

Syntax ​

setClipboard accepts a string or a JavaScript expression:

yaml
- setClipboard: "custom@example.com"  # string
- setClipboard: "${'user' + Math.floor(Math.random() * 1000) + '@example.com'}" # JavaScript expression

Usage examples ​

Set a static value ​

This example puts an email address on the clipboard and pastes it into a field, instead of typing each character. Pasting with pasteText is often more reliable than typing when the text is long or has special characters.

yaml
appId: com.example.app
---
- launchApp
- tapOn:
    id: "emailField"
- setClipboard: "custom@example.com"
- pasteText

Set a dynamic value ​

Use a JavaScript expression to create content that changes on every run, for example a random email.

yaml
appId: com.example.app
---
- launchApp
- setClipboard: ${'user' + Math.floor(Math.random() * 1000) + '@example.com'}
- tapOn:
    id: "emailField"
- pasteText

Access clipboard contents ​

Later steps can read the clipboard content with maestro.copiedText.

yaml
appId: com.example.app
---
- setClipboard: "test@example.com"
- inputText: "${'Email: ' + maestro.copiedText}"