Parameterizing Low-Level Procedures

Applies to TestComplete 15.40, last modified on March 25, 2022
Information in this topic applies to desktop and web applications.

Parameters of events recorded in a low-level procedure hold constant values. They cannot specify a variable or a named constant. This limitation makes a low-level procedure a static entity, which always uses the same set of testing data and always works in the same predefined manner (for instance, always simulate entering of the same string, simulates mouse clicks at the same screen coordinates, etc). Sometimes it is necessary to parameterize a low-level procedure with an external parameter. This lets you use procedures in a more flexible manner since you can re-use the same procedure to simulate user input for different test data.

Parameterizing of a low-level procedures include the following two steps:

  1. Exporting of the low-level procedures to a script.

  2. Editing of event parameters in the script.

To export a low-level procedure to a script:

  • Double-click the desired low-level procedure in the Project Explorer panel. The Low-Level Procedure Editor will open.

  • Select the low-level events that need parameterization. You can use Shift-click and Ctrl-click for multi-selection. To select all the events of the low-level procedure, use the Select All context menu item.

  • Right-click the selected items and choose Export Selected Events to Script from the context menu. The Export to Script dialog will open.

  • In the dialog:

    • Select the name of the script unit that will contain the generated script code (you can also create a new unit, if needed).

    • In the Test name box, enter the name of the script routine to be generated.

      Note: You can export low-level events to a new routine only. After you export the events, you can copy the generated script statements and paste them to the desired location.
    • Click OK to export the events.

The events are exported as calls to the corresponding methods of the LLPlayer object. Method names coincide with the names of low-level events. Parameters passed to each method coincide with the appropriate event parameters.

Note: A low-level procedure may contain window-relative or screen-relative coordinates (see Window- and Screen-Relative Low-Level Procedures). TestComplete does not convert coordinates when exporting them to scripts. The LLPlayer object methods always treat coordinates as screen coordinates.

After a low-level procedure was converted to a sequence of method calls, you can change parameters of these methods and thus parameterize the low-level procedure. For instance, after the conversion, parameters of the LLPlayer.MouseMove method hold constant integer values. You can parameterize the MouseMove method by replacing the initial parameter values with other expression, for instance, with sum of a variable and a numerical value, making this method “dependent” on that variable. To perform the replacement faster, you may employ the replacement features provided by the TestComplete Code Editor and regular expressions. See Finding and Replacing Text in Code Editor.

See Also

LLPlayer Object
Testing Applications in Low-Level Mode
Window- and Screen-Relative Low-Level Procedures
Editing Low-Level Procedures
Running Low-Level Procedures
Finding and Replacing Text in Code Editor

Highlight search results