Simulating Selection of Items and Nodes

Applies to TestComplete 15.47, last modified on January 20, 2023

You can simulate user selection of complex control items and nodes by using special methods of supported controls, native methods and properties of controls and by sending keystrokes to the needed control. You can simulate these actions both from keyword tests and scripts. The information below describes how to simulate actions in your test.

Selection With Special Methods

TestComplete provides a number of test objects to work with various controls that contain items and nodes: Win32ListBox, Win32ListView, Win32TreeView, JList, WPFTreeView and others. These objects provide extended methods and properties that can be used to perform various operations over controls, including simulating selection of items and nodes. For more information on supported controls and on corresponding test objects, see Supported Controls.

Sometimes it is needed to simulate a click on an item of a complex control, such as a list view item, combo box item and so on. For instance, the Win32ListView object (it is used to work with Win32 list view controls) contains the ClickItem and ClickItemR actions to simulate mouse clicks over list view items. The following table provides methods simulating user actions over the items of complex controls:

To select... Use...
A combo box item The ClickItem method of the desired combo box control. For more information, see Selecting Combo Box Items in Desktop Windows Applications.
A list box item The ClickItem, ClickItemXY, DblClickItem or DblClickItemXY method. For more information, see Selecting a Single List Box Item in Desktop Windows Applications.
A list view item The ClickItem, DblClickItem, ClickItemR, SelectItem, HotTrackSelect or FocusItem method of the desired list view control. For more information, see Selecting List View Items in Desktop Windows Applications.
A tree view item The ClickItem, DblClickItem or DblClickItemR method of the desired control, or the Click, DblClick or ClickR method of the desired tree view item. For more information, see Selecting Tree View Items in Desktop Windows Applications.

You can simulate the described actions in your keyword tests and scripts.

To simulate described actions from keyword tests, use the On-Screen Action and Call Object Method keyword operations. Add the operation to your test for that purpose, specify the desired object, select the appropriate method and specify its parameters. For more information on how to perform typical tasks in keyword tests, see Common Tasks for Keyword Test Operations.

To simulate a selection of items and nodes from a script, call the appropriate method from your script. For more information see About Script Tests.

Selection by Sending Keystrokes

You can also use keystrokes to simulate a selection of items and nodes. For detailed information on how to simulate keystrokes in your tests, see Simulating Keystrokes.

Selection With Low-Level and Native Methods

If your tested application used a custom control that cannot be recognized as one of supported controls, then you will not be able to use specific actions or methods to select items in it. In this case, you have to resort to the click, double-click or drag actions described in Simulating Mouse Actions or the MouseDown and MouseUp methods of the Desktop object. You can also simulate actions by using low-level procedures.

Another approach for simulating user actions within a control is to use its “native” methods and properties. This requires that the tested application is an Open Application. In this case, your tests have access to the application’s internal objects, methods and properties and you can use these methods and properties to simulate the desired user action. To find the method or property that can be used to select an item or node, explore the control in the Object Browser. You can also refer the control’s documentation, or ask the tested application’s developers.

You can call the above-mentioned methods from your keyword tests. To do this, use, for instance, the Call Object Method or Run Code Snippet operation. For more information on how to perform typical tasks in keyword tests, see Common Tasks for Keyword Test Operations.

See Also

Simulating User Actions
Simulating Keystrokes

Highlight search results