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:
- setClipboard: "custom@example.com" # string
- setClipboard: "${'user' + Math.floor(Math.random() * 1000) + '@example.com'}" # JavaScript expressionUsage 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.
appId: com.example.app
---
- launchApp
- tapOn:
id: "emailField"
- setClipboard: "custom@example.com"
- pasteTextSet a dynamic value
Use a JavaScript expression to create content that changes on every run, for example a random email.
appId: com.example.app
---
- launchApp
- setClipboard: ${'user' + Math.floor(Math.random() * 1000) + '@example.com'}
- tapOn:
id: "emailField"
- pasteTextAccess clipboard contents
Later steps can read the clipboard content with maestro.copiedText.
appId: com.example.app
---
- setClipboard: "test@example.com"
- inputText: "${'Email: ' + maestro.copiedText}"