Run Script Routine Operation

Applies to TestComplete 15.63, last modified on April 22, 2024

Description

Use the Run Script Routine operation to execute a script function or procedure declared in one of your project’s script units.

Requirements

There must be no syntax errors in your project’s script units. Otherwise, TestComplete will be unable to parse the script code correctly and get the script routine to run.

Operation Result

The operation returns the same result as the script routine which it calls. For information on how to obtain the result value, see Checking Operation Result.

If the script routine does not return any value, the operation also does not return any value.

Scripting Analogue

This operation is a keyword test analogue for calling a script routine from another script routine.

Child Operations

The operation cannot have child operations.

Operation Parameters

The operation parameters specify the name of the routine to run and parameters to pass to the routine if it takes any:

  1. When you add the operation to a test, it shows the Select Test dialog, in which you can select the script routine to execute.

  2. If the selected routine has parameters, the operation shows the Operation Parameters dialog in which you can specify their values.

    If the routine has no parameters, the operation will not show the dialog.

    For Python projects: To learn how to call routines with unspecified number of arguments, see the Remarks section below.

Remarks

  • In Python scripts, it is possible to declare routines that take an unspecified number of non-keyword arguments (*args) or an unspecified number of keyword arguments (**kwargs). See Python Reference - Arbitrary Argument Lists. When calling such routines, the Run Script Routine operation does not support specifying their arguments. As a workaround, you can do the following:

    1. In your script unit, create an intermediate routine that will use the eval statement to call the target routine. For example:

      Python

      def print_All(*items):
        for item in items:
          Log.Message(aqString.Format("%s", item))

      # The intermediate routine
      def stub(a):
        eval('print_All(' + a + ')')

    2. In your keyword test, add the Run Script Routine operation and configure it to call the created intermediate routine. Specify a string value that contains the parameters to pass to the target routine:

      Calling a script routine with a tuple argument

      Click the image to enlarge it.

  • You can add the Run Script Routine operation to a test by dragging the needed script unit from the Project Explorer or the needed script routine from the Code Explorer to the desired location in the test.

    Note: By default, the Code Explorer panel is hidden from TestComplete. To make the panel visible, select View > Select Panel from the TestComplete main menu, and then select Code Explorer in the resulting Select Panel dialog.

See Also

Test Actions Category
Specifying Operation Parameters
Checking Operation Result
Run Code Snippet Operation
Run Test Operation

Highlight search results