inputText
Type text into focused input fields with optional keyboard handling.
the inputText command inputs a specified text string. This command works even if no text field is focused.
Syntax
You can use the shorthand string syntax for quick inputs:
- inputText: "string"You can also use the expanded syntax to include the label:
- inputText:
text: "user@example.com"
label: "Input the test system username"The label parameter provides real-world context in your test reports, making it clear what specific data is being entered during that step.
WARNING
Unicode characters are not supported on Android. See GitHub issue #146 for status updates.
Random text input commands
Astra Scout provides several commands to input randomly generated data.
| Command | Description |
|---|---|
inputRandomEmail | Inputs a random email address. |
inputRandomPersonName | Inputs a random person's name. |
inputRandomNumber | Inputs a random integer. |
inputRandomText | Inputs random unstructured text. |
inputRandomCityName | Inputs a random city name. |
inputRandomColorName | Inputs a random color name. |
inputRandomCountryName | Inputs a random country name. |
Setting the length
The shorthand commands above take no parameters. To control the length, use inputRandom with a type (TEXT, NUMBER, EMAIL or PERSON_NAME) and a length:
| Parameter | Type | Description |
|---|---|---|
type | string | TEXT (default), NUMBER, EMAIL or PERSON_NAME. |
length | integer | Number of characters (TEXT) or digits (NUMBER) to generate. The default is 10. Ignored for other types. |
INFO
inputRandomCityName, inputRandomCountryName and inputRandomColorName pick a value from a small built-in list. They take no length.
Usage examples
You can use the inputText command to add a specific string:
- inputText: "Hello World"You can also input a random number or text with a specific length:
- inputRandom:
type: NUMBER
length: 9
- inputRandom:
type: TEXT
length: 11Reuse a random value in an assertion
This example inputs a random string, copies it to a variable, and then asserts that the copied text is visible on the next screen.
- tapOn:
id: MyTextInput
- inputRandomText
- copyTextFrom:
id: MyTextInput
- tapOn: 'Submit'
- assertVisible: ${maestro.copiedText}In this example, copyTextFrom stores the copied text in the copiedText variable. This value is then used by assertVisible to verify that the generated text appears on the new screen after tapping the Submit button.
Use variables
You can input dynamic data stored in variables or the results of JavaScript expressions.
# Input text from an environment variable or previous output
- inputText: ${USER_EMAIL}
# Input using complex logic
- inputText: ${'testuser_' + Math.floor(Math.random() * 1000)}WARNING
On iOS simulators, inputText can fail on password fields (secureTextEntry) because of iOS Password AutoFill.
