githubEdit

setClipboard

Set text directly to Maestro's internal clipboard for re-use in tests or scripts. This complements copyTextFrom which copies text from UI elements.

You can set text directly to Maestro's clipboard and save it in-memory, to paste later. Unlike copyTextFrom which copies text from UI elements, setClipboard allows you to specify the text directly.

Usage Example

This command is useful when you want to avoid input flakiness by pasting text instead of typing:

appId: com.example.app
---
- launchApp
- tapOn:
    id: "emailField"
- setClipboard: "[email protected]"
- pasteText

You can also use JavaScript expressions in the text value:

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

The clipboard contents can be accessed in JavaScript using the maestro.copiedText property:

Last updated

Was this helpful?