Applies to TestComplete 14.71, last modified on November 27, 2020

Description

The Try, Catch and Finally operations provide the possibility to implement structured exception handling mechanism in your keyword tests:

  • The Try operation groups operations that may cause an error.

  • The Catch operation contains operations that will be executed if an error occurs in the Try block.

  • The Finally block contains operations that will be executed regardless of whether an error occurs in the Try block.

The Try operation must be followed by either Catch, Finally or both these operations at the same level. So, the following constructions are possible: Try... Catch, Try...Finally, Try... Catch... Finally.

Note that the Try and Catch operations only handle exceptions raised by the test engine, like an incorrect number of parameters specified for a test operation or incorrect parameter types, syntax errors in code expressions embedded in the test and others. They do not handle errors that are posted to the test log by TestComplete test objects, methods and properties, like “Object not found”, “Object does not support this property or method” and the like. To handle these errors, create an event handler for the OnLogError event (see About Events and Event Handling).

Operation Result

The operation does not return any value.

Scripting Analogue

The Try operation is an analogue to the try statement of C++, Delphi and other programming languages.

Child Operations

The operation can have any operation as a child.

The Catch and Finally operations that relate to Try must be located after it in the test, they must not be child operations.

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 does not have parameters.

See Also

Statements Category
Catch Operation
Finally Operation

Highlight search results