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:
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:
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 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 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.
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.
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.
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
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
CreateObjectfunction and JScript’s
Use functionality provided by some of TestComplete global scripting objects, such as
aqFileSystemand others (see Objects Available to Script Extensions for the full list of available objects).
Use the TestComplete
Sysobject 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.
Post messages to the test log using the TestComplete
Generate script code using the
Record script code using methods of the
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
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
Regionsand other Stores objects.
Call routines from .NET assemblies and create .NET class instances via the TestComplete
Use the TestComplete
DDTobject to read data from Excel and CSV files and ADO database tables.
Call user-defined routines using the
Display help for your extension using the special
Use runtime objects provided by other script extensions. For example, you can use the
WMIobject provided by the AQAScriptExtensions package that is shipped with TestComplete.
For the full list of objects that can be used in the script extension code, see Objects Available to Script Extensions.