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
    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'

Run file

If you want to run a JavaScript file you can use the runScript command:


Passing parameters

runScript accepts env parameters, in the same way as runFlow does (see Nested Flows).

Passing a parameter:

- runScript:
    file: script.js
       myParameter: 'Parameter'

Reading a parameter in JavaScript:

const readPassedParameter = myParameter;


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 updated