Specifying Operation Parameters

Applies to TestComplete 15.68, last modified on October 03, 2024

To specify parameters of keyword test operations, you can use constant, string or integer values, or variables and parameters of a keyword test, code expressions, project, project suite or network suite variables, and other means. This topic explains how to specify these values.

Note: Some operations do not support all parameter setting modes described in this topic.

How to Choose the Parameter Mode

You enter parameters of keyword test operations in the Operation Parameters dialog or on the Operation Parameters page of the wizard that is displayed when you add or edit operations in your test. By default, you specify the parameter values by entering the needed string or integer constant in the Value column:

Operation Parameters Dialog

You can click the ellipsis button of the Value cell to call the Edit Parameter dialog and specify a parameter in the advanced mode. This way you can specify parameters by using keyword test parameters, keyword test variables, project and project suite variables, network suite variables, or by using code expressions.

Edit Parameter Dialog

In the Mode list, you choose how the parameter is set and then specify the parameter value in the Value edit box. To learn how to use these modes, see below.

Constant Mode

If the Constant mode is selected, the parameter is specified as a string, number, boolean or Variant constant value. For instance in the expression if x = 10 then ..., 10 is an integer (numerical) constant and in the expression Log.Message("Success"), "Success" is a string constant.

To specify the parameter value as a constant:

  • Select Constant from the Mode drop-down list.

  • Select the constant data type from the Type drop-down list (see below).

  • Enter the needed value into the Value box.

  • Click OK to confirm the change and to close the dialog.

The constant value can be one of the following types (you choose the type in the Type combo box):

  • String - Use this type for the parameters that accept text data.
  • Integer - Use this type for the parameters that accept integer numbers.
  • Double - Use this type for the parameters that hold floating-point numbers and dates.
  • Boolean - Use this type for the parameters that store True or False.
  • Object - Use this type for the parameters that store object references, for instance, a reference to the scripting object that corresponds to the tested control. Using parameters of this type you can also pass null and unassigned Variant values.
  • Variant - Use this type for parameters that can be any value, for instance, that can be an integer, string or date. This type can also be used to store object references.

TestComplete automatically changes the type of the Value edit box according to the selected data type of the constant. For example, if you select Boolean in the Type column, the Value column will be a combo box with items: False and True; and if you select Integer, the Value box will become an up-down editor.

Notes:

  • To specify a null or an unassigned Variant value, choose Object from the Type drop-down list and then select Unassigned or Null from the drop-down list of the Value box.

  • To specify a string value, just enter the needed string into the Value box. Do not enclose the string in quotes or apostrophes.

    To specify multi-line text, use Ctrl+Enter to enter a line break.

Code Expression Mode

In the Code Expression mode, you specify the parameter value using a code expression. For instance, in the statement like if Sys.Clipboard <> "MyStr" ..., Sys.Clipboard is a code expression.

To specify the value as a code expression:

  • Select Code Expression from the Mode drop-down list.

  • Enter the needed code into the Value column.

  • To confirm the input and to close the dialog, click OK.

Notes:

  • The specified expression must be just one line of code.

  • The expression should be a function or statement that returns a result. For instance, the expression can be a call to an object’s method that returns a result.

  • To specify the object in the expression, you can click the ellipsis button of the Value edit box and choose the needed object in the ensuing dialog.

Onscreen Object Mode

When the Onscreen Object mode is selected, you specify the value using the property or method of an onscreen or mapped object, or, if the parameter must refer to an object, you specify the parameter by using the object name. This mode is similar to the Code Expression mode, but only lets you specify an object, method or property. Script expressions are not supported.

To specify a value in the Onscreen Object mode:

  • Select Onscreen Object from the Mode drop-down list.

  • In the Value column, specify the name of the needed object or property, or method. To specify the object, you can type its name, or click the ellipsis button and choose the object in the ensuing Select Object dialog.

    Note that if the Map object names automatically setting is enabled in the Name Mapping Options dialog, TestComplete will automatically generate a custom name for the selected object and use this name to address this object.

  • If the edited parameter should refer to an object, you are done. Click OK to confirm the input and to close the dialog.

    If you need to use the property or method of the selected object, type the name of the needed property or method. For instance, if you selected Notepad’s text box, then to obtain the text type, use the following code (the typed code is highlighted with blue, we assume that the text box was mapped):

    JavaScript, JScript

    Aliases.notepad.wndNotepad.Edit.wText

    Python

    Aliases.notepad.wndNotepad.Edit.wText

    VBScript

    Aliases.notepad.wndNotepad.Edit.wText

    DelphiScript

    Aliases.notepad.wndNotepad.Edit.wText

    C++Script, C#Script

    Aliases["notepad"]["wndNotepad"]["Edit"]["wText"]

    After specifying the needed property or method, click OK to save the changes and to close the dialog.

    Note: The string that you type must conform to the syntax rules of your project’s scripting language. Also, the string must not contain line breaks.

Variable

In the Variable mode, you specify the parameter value by using a keyword test variable or a project, project suite or network suite variable:

  1. Select Variable from the Mode drop-down list.

  2. Expand the drop-down list of the Value column and choose the needed variable from the list.

    Note: For project or project suite variables of the String, Integer, Boolean, and Double type, the list shows the current variable value making the choice easier.

  3. Click OK to apply the changes and to close the dialog.

Note:

Network suite variables that your master project specifies are not available in slave projects at design time. The Value list will not contain these variables.

As a workaround, in your slave project, you can create a network suite variable with the same name as your master project’s variable and use it in your tests. When you run your network suite, the master project will copy the needed variable value to the slave project.

You can also use the Run Code Snippet operation to run code that will perform the needed operations over network suite variables.

Test Parameter

If the Parameter mode is active, you specify the parameter’s value by using a parameter of your keyword test:

  • Select Test Parameter from the Mode drop-down list.

  • Choose the needed parameter from the drop-down list of the Value column.

  • Click OK to apply the changes and to close the dialog.

Last Operation Result

This mode is used to retrieve the result of the previously executed operation. To activate this mode, select Last Operation Result from the Mode drop-down list. In this mode, the Value edit box is read-only. It displays Last Operation Result to designate the selected mode.

For detailed information on verifying operations’ results, see Checking Operation Result.

Table Data

This mode is used to retrieve a value from an existing DB table variable. To active this mode, select Table Data from the Mode drop-down list. In this mode, the Value drop-down list contains table variables that are defined in the current keyword test, project or project suite. To specify a table variable:

  • Select Table Data from the Mode drop-down list.

  • Select the name of a table variable, which exists in the current keyword test, in the Value drop-down list.

    Note: To add a new table variable to your keyword test, use either the Data-Driven Loop operation or the Add DB Variable to Keyword Test wizard.
  • Click OK to apply the changes and close the dialog.

For detailed information about the DB table type, see Variables of the DB Table Type.

File Name

Use this mode to input the name of a file stored on your computer or local network. To browse for the needed file, click the ellipsis button in the Value box.

Specifying Enumeration Values in Parameters

Some operation parameters use enumeration values. These is, for instance, the Priority parameter of operations that post messages to the test log or the Shift parameter of methods called by the On-Screen Action or Call Object Method operations.

To specify the values of enumeration parameters, you can choose the appropriate value from a drop-down list in the Operation Parameters dialog, type the value name (for instance, pmLower) or type the numerical analog of the value. For instance, to specify the pmLower priority for a log message, you can either choose pmLower from the drop-down list or enter 200.

Selecting Value From the Drop-Down List
Selecting value from the drop-down list
Typing Value Name
Typing value name
Specifying Numerical Analogue
Specifying numerical analog
In certain cases, TestComplete may be unable to detect that a parameter has an enumeration type. For instance, it can fail to do that for parameters of the application’s native methods. In this case, TestComplete does not display the drop-down list for the parameter, and you have to enter the numerical analog of the needed value.

For some enumeration parameters the drop-down list can include the Use as flags setting. You use it if you need to specify a combination of values specified in the list. This is needed, for instance, for the Shift parameter of the Click method: this parameter specifies keys (Alt, Shift, Ctrl) to be pressed during the click simulation; it can specify an individual key (for instance, Ctrl), or a combination of keys (for example, Ctrl+Shift).

To specify a combination of values:

  • Select Use as flags in the drop-down list.

    TestComplete will display check boxes for each list item.

  • Select check boxes for the needed values in the list:

    The 'Use as flags' mode is active
    The 'Use as flags' mode is active
    The 'Use As flags' mode is inactive
    The 'Use As flags' mode is inactive

    TestComplete will display the resulting expression in the text box above:

    Resulting Expression

    The selected values are combined with the OR operator. Note that its syntax depends on the scripting language of your test project: in VBScript and DelphiScript this is the “OR” keyword; in JScript, Python, C++Script and C#Script this is a vertical line: “|”.

See Also

Keyword Tests
Keyword Tests

Highlight search results