Code Completion

Applies to TestComplete 15.40, last modified on July 05, 2022

About Code Completion

The Code Completion window shows –

  • Objects and their properties and methods.

  • Routines declared in your scripts and routine parameters.

  • Global and local script variables.

  • Statements (if, for, while, and so on) and functions that the scripting language of the current project provides (for example, in DelphiScript projects, it will display the Ord function).

  • Common TestComplete objects (Sys, Log, and others).

  • Objects that provide access to project items (Events, NameMapping, and so on).

    Note: Code Completion will show the objects only if you have the appropriate items in your project.
  • Objects provided by installed extensions (for example, dotNet, DDT).

    Note: You can disable extensions you do not use, so, Code Completion will not show objects those extensions provide. This will make it easier to find the objects you need.

This saves you from checking the language reference and helps avoiding typing errors.

To call the Code Completion window, press Ctrl+Space in the Code Editor.

If the auto pop-up mode is enabled, the editor automatically shows the Code Completion window when you are typing code instructions.

Once opened, the Code Completion window automatically pre-selects the element that was chosen most recently.

To insert an object, property, method, parameter, global or local variable into the script code, double-click its name in the Code Completion window. You also can select the needed item using the keyboard and then press Enter or Tab or click in the Code Completion window.

At the bottom of the Code Completion window, TestComplete displays a description for the selected item.

Note: You also can view the description and parameter information directly in the Code Editor. See Code Parameters.

If a method or property returns an enumeration value, Code Completion will list the enumeration members under the method (or property) node.

Auto Pop-Up

When the Auto Pop-Up option is enabled, Code Completion analyzes the code as you are typing it and shows scripting statements that are valid for the current context. For example, if you type Options. (notice the period at the end), the Code Completion window will appear automatically and show properties and methods of the Options object:

The Code Completion window. Auto Pop-Up option is on.

In addition, the Code Completion window appears when you start typing new instructions in the editor. As you are typing, the Code Completion window will set the focus on the appropriate scripting statement.

Note: For VBScript scripts, the Code Editor does not display the Code Completion window when you start typing a new code instruction. The window will appear after you type a dot at the end of an object’s name, and it will display the object’s properties and methods. To call the Code Completion window manually, press Ctrl+Space and you will see a list of available scripting statements.

To fill the Code Completion window, TestComplete parses the entered code while you are typing it. During the analysis, it attempts to determine the object type that corresponds to the current insertion point. It can detect variable assignments and process them. For example, if you enter the following VBScript script code —

VBScript

Set w = Sys.Desktop
Set w2 = w
w2.

TestComplete will detect that the w2 variable holds a reference to the Desktop object, and the Code Completion window will show methods and properties of the Desktop object.

To determine the object to which a variable refers, TestComplete scans the code upward from the position where Code Completion is called, and uses the first found variable assignment. The search algorithm ignores conditional statements. That is, if you assign the variable in the if… then block, TestComplete ignores this block, but uses the assignment to determine the object that the variable stores.

It may take a while for Code Completion to parse the code and get the list of members to show. While the parsing is in progress, the Code Completion window will show the Evaluating message. You can continue typing the code while the parsing is still in process or you can stop the parsing by closing the Code Completion window.

Parsing will fail if the entered code contains errors. In this case, TestComplete will use the parsing data it has gotten before the error occurs. After you fix the error, Code Completion functioning resumes. For more information on parsing script code, see Checking Syntax.

If TestComplete cannot determine which routines, methods, properties or script statements are valid in the current context, the Code Completion window will not appear. This happens, for example, when TestComplete cannot determine the type of the object to which a script variable refers.

Item Icons Displayed in the Code Completion Window

Each item shown in the Code Completion window has one of the following icons:

  • - Object: This icon is used for objects that do not provide specific icons. If an object has a specific icon (for instance, DLL - ), Code Completion displays a specific icon.
  • - Namespace of objects provided by a script extension.
  • - Method or script routine that does not return a value (procedure).
  • - Method or script routine that returns a value (function).
  • - Global or local script variable, script routine parameter, field or writable property.
  • - Constant or read-only property.
  • - Enumeration value.
  • - Scripting language keyword.

The trailing brackets in the item caption indicate that the item is an indexed property.

See Also

Code Editor
Code Templates
Code Parameters

Highlight search results