copyTextFrom
Copy text content from a UI element to clipboard or variable.
The copyTextFrom command copies text from a UI element and stores it in memory. This command requires a Selector to identify the target element.
Accessing the copied text
When you copy content using the copyTextFrom command, you have two ways to use the text after it has been copied:
Use the
pasteTextcommand to immediately insert the content into a focused field.To run an equality check, perform complex logic, or store the text for later use in your flow, use the
maestro.copiedTextvariable.
Usage examples
The following examples demonstrate how to use the copied text.
Paste with the pasteText command
This example copies text from an element with the ID someId and pastes it into a search field.
appId: com.example.app
---
- launchApp
- copyTextFrom:
id: "someId"
- tapOn:
id: "searchFieldId"
- pasteTextAccess with JavaScript
The copied text is available in JavaScript through the maestro.copiedText property. This example copies the text from someId and uses the inputText command to add the content into the search field.
Store and validate
You can assign the copied value to a custom variable to perform assertions or use it later in a Flow after other commands have overwritten the clipboard.
This example demonstrates how to copy text from a UI element, store the copied value in a variable using maestro.copiedText, and then validate that the captured text matches the expected value.
Related content
Last updated