Script Extensions - Overview

Applies to TestComplete 14.10, last modified on June 5, 2019
What are Script Extensions?

The script extensions technology is used to create plugins for TestComplete. Unlike “traditional” plugins that are created with Visual C++ and Delphi, script extensions are created in JScript or VBScript. This makes the creation of plugins easier and enables users, who have little or no programming experience, to extend the TestComplete functionality.

What can I do with Script Extensions?

The script extensions technology enables you to create TestComplete extensions of the following kinds —

  • Custom record-time actions

    Record-time actions are commands that can be executed when the user records a test. These actions are added to the TestComplete Recording toolbar once the extension is installed, and can be executed by selecting the appropriate item from the toolbar:

    Custom record-time actions on the Recording toolbar

    Record-time actions allow you to perform various operations during recording. For example, you can have an action that creates a custom checkpoint, generates the corresponding validation code and inserts this code into the script that you are recording.

  • Custom design-time actions

    Design-time actions are commands that users can execute while they are editing tests. After the extension is installed, TestComplete adds its design-time actions to the Tools toolbar:

    Custom design-time actions on the Tools toolbar

    Design-time actions are designed to assist you with test creation. For instance, they can create checkpoints for you or generate script code and insert it into your test script.

  • Custom scripting objects

    Script extensions provide an easy way to extend the TestComplete object model with custom objects. Objects provided by script extensions appear in the Code Completion window and can be used in test scripts like any other TestComplete scripting object.

    Custom runtime object in the Code Completion window
  • Custom keyword test operations

    With script extensions, you can create custom operations that can be used in keyword tests. Once the extension is installed, the keyword test operations it provides are added to the Operations pane of the TestComplete Keyword Test editor:

    Custom operation in the Operations palette

    Custom operations can perform any actions you need. For example, they can provide custom checkpoint types, perform some common tasks or serve as wrappers for frequently used script object methods.

  • Custom operations on test results

    Script extensions allow you to add custom test log processing commands to TestComplete. These commands are added to the test log’s toolbar once an extension is installed.

    Custom commands in the test log

    Typical examples of custom operations on test results are commands for submitting the test log to an issue-tracking system that is not supported by TestComplete out-of-the-box.

Like all TestComplete features, script extensions are language-independent. This means that they work equally well in JavaScript, JScript, Python, VBScript, DelphiScript, C#Script and C++Script projects regardless of the language that was used to create the extension.

Script Extensions vs. Traditional Plugins

The TestComplete SDK lets you create plugins for extending TestComplete. These plugins can be developed in Delphi or Visual C++. We refer to them as “traditional” plugins.

The creation of traditional plugins require programming experience in Visual C++ or Delphi. However, by using these plugins you can extend almost any TestComplete subsystem. For example, you can extend the user interface and the project items’ set, in addition to the commands subsystem and the object model. With script extensions you can only create custom actions and objects. Also, C++ and Delphi, as object-oriented languages, provide more powerful features for creating the plugins’ code.

However, script extensions are much easier to create than traditional plugins. First of all, their code is written in scripting languages which are easy-to-use -- JScript or VBScript (JavaScript, Python and DelphiScript are currently not supported). This frees you from having to learn another language or a programming language just to extend TestComplete. Then, there is also no need for a special development environment -- the scripts can be written in any text editor, for example, Notepad, or even TestComplete itself.

The concept of “traditional” plugins and script extensions is similar to the concept of add-ons and macros in Microsoft Office products. Plugins are like add-ons: they are powerful, but labor intensive. To create them you need some programming experience and knowledge of COM. Script extensions are like macros: they are easy to create, but less powerful.

Script Extensions vs. Shared Script Units

TestComplete lets you share script units between multiple projects, thus enabling you to create common script libraries. A script unit can be imported into a project, and thus expose common routines to the rest of the project’s unit.

Shared script units must be added to each project in which you wish to use them. This means that if you have, say, a dozen of projects, you need to manually add the common unit to each project and insert the USEUNIT / uses statements in each script where you want to access common routines. Script extensions, on the contrary, are installed in TestComplete itself and are only installed once. After that, the runtime objects they provide become available to all projects you work on.

Another specific of using shared scripts is that a unit can be imported into a project only if they use the same language. That is, one cannot add a VBScript unit into a JScript project. This restriction does not apply to script extensions -- the objects they provide can be used in any TestComplete project, regardless of its language. That is, you can use VBScript extensions in JScript or DelphiScript projects, or use JScript extensions in your VBScript or DelphiScript code.

What Functionality can be Used in Script Extensions?

In the script extension code you can:

  • Use the intrinsic functionality of the chosen scripting language (JScript or VBScript) to perform the desired actions. Note, that this includes not only routines to work with various value types, but also the possibility to create instances of COM objects (such as Excel.Application) or any other components that have scripting API (such as the Windows WshShell object) with the VBScript’s CreateObject function and JScript’s new ActiveXObject statement.

  • Use functionality provided by some of TestComplete global scripting objects, such as aqString, aqFileSystem and others (see Objects Available to Script Extensions for the full list of available objects).

  • Use the TestComplete Sys object to address processes, work with their windows and controls, check the properties of this object and call methods on it. In fact, script extensions can work with processes and onscreen objects just like ordinary TestComplete scripts can.

  • Display forms prompting the user to enter or select some values, and obtain the user input. This can be done through the TestComplete UserForms object.

  • Post messages to the test log using the TestComplete Log object.

  • Generate script code using the Syntax object.

  • Record script code using methods of the Recorder object.

  • Obtain the contents of the active Code Editor as well as modify the currently opened script: insert new code snippets, replace code, and so on. This functionality is provided by the CodeEditor object.

  • Manage files, images and objects stored in the Stores project item: add and remove new items, compare actual items against their stored copies, etc. To do this, you can use the TestComplete Files, XML, Regions and other Stores objects.

  • Call routines from .NET assemblies and create .NET class instances via the TestComplete dotNET object.

  • Use the TestComplete DDT object to read data from Excel and CSV files and ADO database tables.

  • Call user-defined routines using the Runner.CallMethod method.

  • Use the TestComplete Project and ProjectSuite objects to obtain general information about the user’s current project and project suite, manage variables defined in them and access test logs’ data.

  • Display help for your extension using the special Help object.

  • Use runtime objects provided by other script extensions. For example, you can use the WMI object provided by the AQAScriptExtensions package that is shipped with TestComplete.

  • And much more!

For the full list of objects that can be used in the script extension code, see Objects Available to Script Extensions.

See Also

Script Extensions
Objects Available to Script Extensions

Highlight search results