Run JavaScript
There are several ways to run JavaScript, depending on your needs.
Everything within
${}
blocks is evaluated as JavaScript, allowing you to insert dynamically computed values into any other Maestro command.appId: com.example
env:
MY_NAME: John
---
- launchApp
- inputText: ${1 + 1} # Inputs '2'
- inputText: ${'Hello ' + MY_NAME} # Inputs 'Hello John'
- tapOn: ${MY_NAME} # Taps on element with text 'John'
If you want to run a JavaScript file you can use the runScript command:
- runScript:
file: script.js
env:
myParameter: 'Parameter'
For very simple computations (like the one above), creating a new file might be cumbersome. For this use case you can use the
evalScript
command:Last modified 4mo ago