Parameterize scripts

When you parameterize a script, you replace constant values in the script with parameters. This allows you to re-use steps and create more flexible scripts.

Overview

A script can have input parameters and output parameters. Use an input parameter to pass a value to a step or describe an object. Use an output parameter to store the output value of a step to use later.

Create and manage your scripts' parameters in the Script parameters pane, and use them in your script steps.

In MBT, open a Unit's Parameters tab to view and modify the parameters of the codeless script you associated with the unit.

The following sections describe how to use parameters to pass values to a step or store output values:

Back to top

Create parameters

In the Script parameters pane, you can create, rename, and delete parameters. You can also define the default values to use for each input parameter. You don't have to create all the parameters in advance. You can also create them when editing your script steps.

To create a parameter:

  1. In the upper right corner, click the @ icon.

    The Script parameters pane opens.

  2. Click + Create new.

    The Add New Input/Output Parameter dialog box opens

  3. Enter an unique parameter name. For input parameters, define a default value.

    • When you name a parameter, consider the following restrictions:

      • Case-sensitive

      • Must begin with a letter

      • Cannot contain spaces

      • Cannot contain the following characters: ! @ # $ % ^ & * ( ) + = [ ] \ { } | ; ' : " , . / < >

    • Only String type parameter values are supported.

To manage parameters in the Script parameters pane:

  1. To modify a parameter's name or value, select an input or output parameter and click the Edit button.

    When you change the name of a parameter, the parameter name is also changed in any steps that use this parameter.

  2. To delete an input or output parameter, select a parameter and click the Delete button.

    Before deleting a parameter, make sure it is not in use by any steps. After deleting the parameter, any steps that used it are marked as incorrect.

Back to top

Pass a value to a step

You can use an input parameter to pass a value to a step.

To pass a value to a step in the Editor:

  1. Open a codeless automation script.

  2. Select the step in which you want to use an input parameter.

  3. Hover over the value or the object name in the step until the cursor changes to a hand pointer.

    Click the value or object name to open the parameter list.

    Alternatively, you can type @ in the step line to open the list of parameters. Make sure to type the @ in a place in the step where it is relevant to insert a parameter.

  4. In the parameter list, select an existing input parameter or click + New parameter to create a new one.

    The value or object name in the step is replaced with the selected parameter.

  5. To convert back to the original constant value, hover over the parameter, click it, and turn off the Use Input Parameter option.

To pass a value to a step in the step editing pane:

  1. Open a codeless automation script.

  2. Select the step in which you want to use an input parameter.

  3. Click the icon next to the Text identification or Value input box.

    Note: Parameters are supported only for specific object classes.

  4. In the parameter list, select an existing input parameter or click + New parameter to create a new one.

    The parameter is automatically added to the Text identification or Value input box and the step.

  5. To convert back to the original constant value, click the icon again and turn off the Use input parameter option.

Back to top

Store a value in an output parameter

You can pass a constant value, the value of an input parameter, or the value of an AI object into an output parameter.

To pass... Type...
a constant value

Set "value" into @<output parameter name>

the value of an input parameter

Set @<input parameter name> into @<output parameter name>

the value of an AI object

Type one of the following syntax:

  • Set value of '<text for identification>' <control type> into @<output parameter name>

  • Set '<text for identification>' <control type> value into @<output parameter name>

When you type @ in the step line after a Set command, a parameter list opens for you to select or create an output parameter:

You can also hover over an empty line, click , and select Set output param to insert the Set "value" into @<output parameter name> syntax.

To store the step result in an output parameter:

In the step editing pane, you can save the result of a conditional step or a verification step in an output parameter. For details, see Add conditional steps and Add verification steps.

Back to top

See also: