About Working With Application Objects and Controls

Applies to TestComplete 15.10, last modified on December 15, 2021

TestComplete provides a number of test objects corresponding to controls in applications—buttons, check boxes, list boxes and so on—and uses these test objects to record and play back operations over controls. Each test object has a number of methods and properties used to perform various operations over controls. For instance, you can get text an object shows, click buttons, select and unselect check boxes, select items in lists, enter values in grid cells, and so on. For example, the following code enters the word Test in Notepad:

JavaScript, JScript

Sys.Process("Notepad").Window("Notepad", "*").Window("Edit").SetText("Test");

Python

Sys.Process("Notepad").Window("Notepad", "*").Window("Edit").SetText("Test")

VBScript

Sys.Process("Notepad").Window("Notepad", "*").Window("Edit").SetText "Test"

DelphiScript

Sys.Process('Notepad').Window('Notepad', '*').Window('Edit').SetText('Test');

C++Script, C#Script

Sys["Process"]("Notepad")["Window"]("Notepad", "*")["Window"]("Edit")["SetText"]("Test")

Here, the Windows("Notepad") object corresponds to the main window of the Notepad application, and the Window("Edit") one corresponds to the edit area of the Notepad window.

For objects in Open Applications, TestComplete also exposes native object methods and properties (defined in the application code), which you can use to perform specific operations or checks. For a complete list of methods and properties available for an object in your application, explore this object in the Object Spy or Object Browser.

How TestComplete assigns a tested object to an application control

When TestComplete accesses a control in a tested application, it checks the control’s class name against the class names of the supported controls.

You can view the list of supported control classes in the Object Mapping list of your current project:

Supported controls specified for the current project

Click the image to enlarge it.

For example, Windows text box controls of the Edit class are associated with the Win32Edit test object. If the application uses custom controls, it is possible to map them to compatible standard classes and associate them with the corresponding built-in test objects.

How TestComplete records actions over controls using associated test objects

When recording and simulating actions over objects in applications, TestComplete uses the following principles:

  • All the methods that simulate user actions over an object (Click, ClickItem, Select, Keys and others) activate the application window containing that object. The only exception is Sys.Keys—it simulates keypresses in the currently focused window or control.

  • All the methods that simulate actions over an item in an object automatically scroll the item into view so that it becomes visible. In tree-like controls, the parent items are automatically expanded to make the target nested element visible.

  • For each method that operates on an individual item in a control (such as a list element or a grid column), you can specify the desired item using the item’s index or caption.

    If the item's caption changes in different contexts (for example, it contains some numeric ID, current date/time or changes from one locale to another), you can use wildcard characters (* and ?) or regular expressions to indicate variable parts of an item's caption. The asterisk (*) corresponds to a string of any length (including an empty string), the question mark corresponds to any single character (including none). To specify more complicated parts of a caption, use regular expressions.

    The methods can treat captions as case-sensitive or case-insensitive, depending on the Use case-sensitive parameters project setting (you can change it on the Properties page of your project’s editor).

  • Items in owner-drawn controls are identified by their index or ID. See Testing Owner-Drawn Controls.

Extra techniques for working with objects

Automating objects in applications is not limited to using test objects only. For example, you can manipulate objects via COM interfaces or DLL functions, use low-level recording and playback modes to draw objects on canvas and so on. To learn more about additional techniques for working with objects in applications, see Interacting With Non-Compatible Application Objects.

See Also

Working With Application Objects and Controls
Object Mapping
Interacting With Non-Compatible Application Objects

Highlight search results