Creating Keyword Test Operations - Basic Concepts

Applies to TestComplete 12.60, last modified on September 17, 2018

This topic describes the process of creating custom keyword test operations 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 operation

    First of all, you need to decide which functionality you want in the operation and which actions it will perform. For example, if you need a custom checkpoint operation, here’s what it could do:

    • At design-time:

      • Display a form that prompts the user to select the object to be verified and specify the checkpoint options.

      • Save a baseline copy of the specified object to the Stores | Objects collection of the user’s current project. Or retrieve data from the control and save this data, say, to a CSV file in the Stores | Files collection.

    • At run time:

      • Verify the actual instance of the specified object against the baseline copy and log the results.

  • Defining the operation name

    The operation name (along with the icon) is used to identify the operation in the Operations panel of the Keyword Test editor and in tests. This name must be meaningful and must reflect the operation’s purpose, so that the users can easily understand what the operation does. For example, if the operation verifies data in an HTML table, you can name it HTML Table Checkpoint.

    The operation name can coincide with the names of other operations, however, it is not recommended, because it may confuse the users. It is recommended that the operation name is unique.

  • Defining the operation category

    All operations displayed in the Operations panel are organized into categories, which group operations according to their purpose: Checkpoints, Test Actions and others. Categories make it easier for the testers to locate the needed operation in the list.

    You can specify the name of an existing category where TestComplete should all your custom operation, or a custom category name. If an operation does not have a category specified, TestComplete will add it to the Custom category.

  • Defining operation parameters and internal fields

    An operation can have parameters and/or internal fields. They are meant to store operation-specific data that affects the operation behavior and results. For example, if the operation is a wrapper for a certain scripting object’s method, the operation can have the same parameters as the method. If the operation provides a custom checkpoint, it can have parameters that specify the object to verify and the checkpoint options. And so on.

    The difference between parameters and fields is that fields are only available in the operation code, whereas parameters are also available to the user. For more information about parameters and fields, see Creating Operation Parameters and Fields.

  • Writing the operation code

    One of the major steps in creating a custom keyword test operation is writing a script routine that will be executed by the operation during the test run. It is this routine that implements the operation functionality. In fact, writing the operation code does not differ much from writing test automation scripts since major TestComplete objects such as Sys, Files, DDT 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 custom keyword test operations, see Writing Operation Code.

    Note that custom keyword test operations are language-independent: they can also be used in any TestComplete project no matter which language it uses and in which language the operation is written. Your choice between JScript or VBScript as the language for writing the operation’s code can be based solely on your personal preferences.

    You can find examples of keyword test operation 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.

  • Defining data to display in the Keyword Test editor

    The Keyword Test editor, which it used to create, view and modify keyword tests, displays various data about operations, such as the operation name, description, and so on. This data is used to identify the operation within the test and to determine its current configuration. To learn how to specify the data to display in the Keyword Test editor, see Customizing KeywordTest Editor Contents.

    Many operations also support in-place editing of their data and thus free the users from calling the operation’s edit form to do minor changes. Implementing in-place editing support for an operation requires some additional script code, but results in better user experience. For more information, see Implementing In-Place Editing Support

  • (Optional) Creating the operation’s edit form

    Besides in-place editing in the Keyword Test editor, custom operations can use forms to provide visual access to their parameters. This edit form is displayed when the user adds the operation to the test or double-clicks an existing operation in the test. See Creating the Operation Setup Routine and Using Forms in Script Extensions.

  • (Optional) Making the operation recordable

    By default, custom keyword test operations are only available at test design time, so that testers can manually add then into their tests. However, if your custom operation wraps certain actions a tester can perform during test recording, you may find it useful to implement the recording support in your operation. In this way, you can enable TestComplete to record your custom operation instead of the corresponding lower-level standard operation(s). See Implementing Recording Support.

  • (Optional) Creating the operation icon

    You can create an icon for your custom operation to help the users quickly identify it. This icon will be displayed next to the operation name in the operations palette and in tests. 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.

  • Adding operation definition to the description file

    The last step is to add information about the operation to the description.xml file of the script extension package. Keyword test operations are defined the KDTOperation element of the file’s XML markup. This element has attributes to specify the operation name and category. The operation’s parameters and internal fields are defined using the child Parameters and Data elements of the KDTOperation element. The KDTOperation’s child Columns element is used to specify the data to displayed in the Keyword Test editor. The main routine executed by the operation as well as various event handlers are specified in the Events element. 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 Keyword Test Operations

Highlight search results