Creating Actions - Basic Concepts

Applies to TestComplete 15.68, last modified on October 16, 2024

This topic describes the process of creating custom record-time and design-time actions with script extensions. It assumes that you are familiar with common procedures of script extension development described in the Creating Script Extensions - Basic Concepts topic.

  • Planning the action

    First, decide which functionality you need in the action and think about the sequence of operations that the action will perform.

    Suppose you need a quick way to add a checkpoint that will verify data in a certain third-party control. If so, your custom action could —

    • Display a form that prompts you to select the object to be verified and specify the checkpoint options.
    • Save a baseline copy of the selected control to the Stores | Objects collection of the project that is currently opened in TestComplete. Or, retrieve data from the control and save this data, say, to a CSV file in the Stores | Files collection.
    • Generate script code that performs the checkpoint.
      Tip: If the comparison code consists of many statements, the code generation process can be complicated. You can simplify the checkpoint code by creating a helper runtime object that will perform the verification. In this case, you would only need to generate a call to this object. To learn how to create custom objects, see Creating Runtime Objects.
    • Insert the generated code into the script being recorded (in case the action works during the recording), add it to the currently opened script or copy it to the clipboard (in case the action is performed during the design time).
  • Writing the action code

    The main step in creating an action is writing a script routine that implements the desired functionality. Writing the action code does not differ much from writing test automation scripts since major TestComplete objects such as Sys, Files, Regions and others are available in the script extension code as well (for a full list of available objects, see Objects Available to Script Extensions). For more information about writing the source code of actions, see Writing Action Code.

    Note that custom actions are language-independent: they can also be used in any TestComplete project no matter which language it uses and in which language the action is written. You can choose the language for writing the action’s code -- JScript or VBScript -- based on your personal preferences.

    You can find examples of actions’ code in the <TestComplete>\Bin\Extensions\ScriptExtensions\AQAScriptExtensions.tcx file that is shipped with TestComplete. This file is a ZIP archive, so you can extract files from it using any archiver that supports ZIP files. For more information about files included in this package, see Pre-Installed Script Extensions.

  • (Optional) Creating the action icon

    It is possible to associate a meaningful icon with an action. This icon will be displayed next to the action name in the action list, or on the toolbar when the action is active. The icon must be a 16×16 BMP or PNG file with the 24-bit or lower color depth; the color of its leftmost-bottom pixel is treated as transparent.

    If the action does not have an icon, the corresponding toolbar item will display the action name.

  • Adding information about the action to the description file

    Finally, the action needs to be defined in the description.xml file of the script extension package. You do this using special elements of the file’s XML markup: record-time actions are defined by the RecordAction elements, design-time actions - by the DesignTimeAction elements. The action definition includes the action name, the name of the routine that the action calls and the action’s icon file, all specified in the appropriate attributes of the mentioned XML elements. For more information about writing the description file, see Structure of the Description File.

    You can find a sample description file in the <TestComplete>\Bin\Extensions\ScriptExtensions\AQAScriptExtensions.tcx file that is installed along with TestComplete.

See Also

Script Extensions
Creating Script Extensions
Creating Custom Actions

Highlight search results