Creating and Recording Keyword Tests

Applies to TestComplete 14.0, last modified on January 23, 2019

With TestComplete you can create keyword tests in one of the following ways:

  • You can create a keyword test when creating a new project.

  • You can add a new keyword test to an existing project.

  • You can add an existing keyword test to your project.

  • You can record a keyword test like you record script code or low-level procedure.

In order for you to be able to add keyword tests to your project, the project must contain the Keyword Testing project item (this item is shown in the Project Explorer as a KeywordTests node).

Creating a keyword test via the context menu of the Project Explorer

You can create a keyword test in the same manner as you create other project elements:

  • Right-click the KeywordTests node in the Project Explorer panel and choose Add | New Item from the context menu.

  • In the subsequent Create Project Item dialog specify the name of the test and the name of the file that will store it. Then, click OK.

TestComplete will create the test with the specified name and location and show it as a child node of the KeywordTests node in the Project Explorer panel. Note that the created test is empty. Therefore, you will have to add operations to it in the Keyword Test editor.

Adding an existing keyword test

To add an existing keyword test to your project:

  • Right-click the KeywordTests node in the Project Explorer panel and choose Add | Existing Item from the context menu. This will invoke the standard Open File dialog.

  • In the dialog, choose the file of the desired test and click Open.

TestComplete will add the test file reference to your project and will display the test in the Project Explorer panel as a child of the KeywordTests node. You can then modify the test in the Keyword Test editor.

Recording keyword tests

In TestComplete you can either create a new empty keyword test and then open the test in the Keyword Test editor and add operations to it, or you can record a keyword test in the same manner as you record scripts or low-level procedures.

TestComplete can start recording in Script or Keyword Test mode. If you start recording in Script mode, you can switch to the Keyword Test mode and the recorded script will contain script instructions that runs the keyword test from a script. That is, the keyword test becomes a part of a bigger test (script routine) that runs over your application.

If you record in Keyword Test mode, the recorded user actions are stored to a keyword test and no additional code is created.

To start recording in Keyword Test mode:

  • Select Record Keyword Test from the TestComplete Test Engine toolbar, or choose Test | Record | Record Keyword Test from the TestComplete main menu, or select Record New Test from the toolbar of the Keyword Test editor.

    TestComplete will create a new keyword test and insert the recorded commands into it.

    Note: You can also add operations to the current test by selecting  Append to Test from the Keyword Test editor’s toolbar. If the Specify the position to append the operation to option is enabled (default), TestComplete displays a message asking you where to append the recorded operation. Click To End to add the recorded operations to the end of your keyword test. Click To Current Position to add the recorded operations to the keyword test after the selected operation. If you click this button and no one operation is selected in the Keyword Test editor, the recorded operations will be added to the end of your keyword test.
  • After starting the recording, you can perform the desired actions on the application under test.

    During the recording TestComplete displays the Recording toolbar where you can pause or stop recording, or command TestComplete to record other tests (scripts or low-level procedures). If you command TestComplete to record these tests, the recorded keyword test will contain operations that run the appropriate tests. For instance, if you switch to the script recording, the keyword test will contain the Run Script Routine code that calls this script routine.

  • To stop recording, press Stop from the Recording toolbar.

If you started recording in script mode, then you can record a keyword test by selecting Keyword Test from the Test Type menu of the Recording toolbar. At that, the recorded script code will contain an instruction that runs the keyword test:

JavaScript, JScript

...
KeywordTests.KeywordTest1.Run();
...

Python

...
KeywordTests.KeywordTest1.Run()
...

VBScript

...
KeywordTests.KeywordTest1.Run
...

DelphiScript

...
KeywordTests.KeywordTest1.Run;
...

C++Script, C#Script

...
KeywordTests["KeywordTest1"]["Run"]();
...

See Also

Keyword Tests
Keyword Testing - Overview
About Keyword Test Editor
Recording Tests
Testing Android Applications
Testing iOS Applications
Adding and Removing Project Items and Their Child Elements

Highlight search results