About Syntax Subsystem

Applies to TestComplete 14.10, last modified on June 5, 2019

TestComplete includes a special syntax subsystem that provides a universal way of generating the script code. This subsystem frees other subsystems (for instance, the recording engine) from having to know specifics of the scripting languages supported by TestComplete. For example, the test engine may “ask” the syntax subsystem to generate the scripting code statement that will assign a value to a variable and the syntax subsystem will produce the appropriate code statement.

The syntax subsystem treats script code as a collection of syntax elements, each of which corresponds to a specific operation, expression or statement. These elements are language-independent, so that by processing them the syntax subsystem can generate source code for any scripting language supported by TestComplete.

In script extensions, you can make use of the following syntax elements:

Object Description
AssignSyntax Corresponds to an assignment statement.
CollectionSyntax Corresponds to a collections of code statements.
ConditionSyntax Corresponds to an expression that contains a comparison or logical operator.
IfSyntax Corresponds to a conditional (if ... then or if ... then ... else) statement.
InvokeSyntax Corresponds to an expression that contains a variable or property name or a call to a routine or an object’s method.
VarDefSyntax Corresponds to a variable declaration statement.

Though this set of elements does not cover all possible expressions and statements (for example, there are no available syntax elements that correspond to loops), it is quite enough to generate the script code for various checkpoints, which is one of the main purposes of script extensions.

To better understand which syntax elements correspond to which code parts, please see the example below. Suppose we have the following code:

VBScript

Dim Text

Text = "Some text"

If Sys.Clipboard <> Text Then
  Log.Error "Clipboard checkpoint failed."
End If

The image below illustrates the correspondence between various parts of this code and the script objects:

To create instances of the syntax elements in script extensions, you can use the corresponding methods of the Syntax object: CreateAssign, CreateCondition and others. The Syntax object also contains the GenerateSource method for generating the script code based on the syntax elements, in the language used in the user’s current project, and the CurrentLanguage property for identifying that language.

For detailed information and examples of generating various scripting statements in script extensions, see the topics of the Generating Script Code section.

See Also

Generating Script Code
Syntax Object

Highlight search results