Skip to content

Writing Scripts

Tomer Atar edited this page Mar 21, 2022 · 2 revisions

V1 scripts

SMAR scritps operate similar to CommonJS modules, altough not all capabilities are present SMAR runs the scripts in node vm, with an isolated context;

The context exposes:

  • __dirname of the script and of scritps required by the script
  • require() function, similar to CommonJS/Node require, but does not cache required objects and can only resolve modules using relative paths.

the script needs to expose the following:

  • version - currently there is only v1, but incase script structure changes, a version needs to be supplied in order to infer script contents correctly
  • parameters - an array of Parameter objects, used to generate UI to allow script parameter value configuration in the application
  • script - a function with two parameters - api, parameters
    • api - contains abstractions used to streamline virtual user input, as well as references to the status of the execution.
    • parameters - an object where its keys are the ids of the controls configured in the parameters export, and the values are the values collected from the selected profile

Please note: In order for the script to abort gracefully, api exposes a flag running Check if the script is still running before executing extensive actions (This may change in a later version to cause an exception automatically)

Clone this wiki locally