Calling Project Items From Scripts

Applies to TestComplete 15.40, last modified on March 25, 2022

For each project item TestComplete provides special program objects that let you work with project items from scripts. For instance, these objects let you execute tests provided by project items, or get project items’ property values.

You can address project elements from scripts using the element name as it is shown in the Project Explorer panel. You do not need to specify the project's name before the desired project item's name. For instance, to execute a keyword test from a script, you can use the following code:

The KeywordTests node in the Project Explorer

JavaScript, JScript

KeywordTests.Test1.Run();

Python

KeywordTests.Test1.Run()

VBScript

KeywordTests.Test1.Run

DelphiScript

KeywordTests.Test1.Run;

C++Script, C#Script

KeywordTests["Test1"]["Run"]();

Here KeywordTests is the name of the Keyword Testing project item as it is shown in the Project Explorer. Test1 is the name of the desired keyword test.

Similarly, you can run tests provided by other project items (Distributed Testing, Selenium or Unit Testing and so on). For more information on how to do this, see the description of the appropriate project item.

To obtain information on methods and properties of an object, type the object’s name and then press Ctrl+Space. This will invoke the Code Completion window that lists the methods and properties of the object.

Note: You can call the items of the current project only. It is not allowed to call an item of Project1 from a script of Project2.

See Also

Script Tests
About Script Tests
Writing Scripts - Quick Start

Highlight search results