If... Then Operation

Applies to TestComplete 14.40, last modified on April 22, 2021

Description

Use the If... Then operation to check conditions in your keyword tests and execute operations according to the result of the check. The operation checks the condition, which is specified by operation parameters, and if the condition evaluates to True, the operation executes child operations.

The operations that should be run if the condition evaluates to False, place the Else operation directly after If... Then. TestComplete will detect the If... Then... Else block and if the condition is False, will switch the execution flow to the Else operation.

The If... Then Operation

Operation Result

The operation returns True or False to indicate the result of the specified condition.

Scripting Analogue

The operation is analogue to the if statements in program languages like C++, Visual Basic or Delphi.

Child Operations

The operation can have any number of any operations as children.

If you use the Else operation along with If... Then, place this Else operation after If... Then and at the same level.

For information on how to make an operation a child of another operation, see the description of the Keyword Test editor’s Test Steps page.

Operation Parameters

The operation has only one parameter: the condition to be checked. You specify this condition in the Operation Parameters dialog:

Parameters of the If... Then Operation

The condition may contain one or several comparison expressions. In the last case, the expressions are combined with each other with the AND and OR operators.

Each row in the dialog corresponds to a comparison expression. The expression has two operands (Value 1 and Value 2) and the comparison operator between them. To specify the operator, simply select the desired value from the drop-down list of the Condition column.

To specify values

To specify the values (operands), use the columns under the Value 1 and Value 2 bands. Each value can be specified in one of the following modes:

  • Constant
  • Expression
  • Variable
  • Test Parameter
  • Last Operation Result
  • Onscreen Object

The values are specified in the same manner, in which you specify operation parameters. See Specifying Operation Parameters for detailed information.

To add an expression

All the expressions that make up the condition are combined with each other with the AND or OR operators. To add a new expression to the condition:

  • Select the expression, with which a new expression will be combined.

  • Click And or Or to specify the desired operator. The row for the new expression will be displayed in the Operation Parameters dialog.

  • Specify the expression’s values and condition.

To delete an expression
  • Select the desired expression in the dialog.

  • Click Remove.

To delete all the expressions, press Clear.

See Also

Statements Category
Specifying Operation Parameters
Else Operation
If Object Operation

Highlight search results