Working With Tree View Controls - Basic Concepts in Desktop Windows Applications

Applies to TestComplete 15.63, last modified on April 23, 2024
General Notes

TestComplete lets you record and replay user actions over tree view controls in Windows applications. It simulates actions over tree view items using various methods of the Win32TreeView object - ClickItem, ExpandItem and others. The Win32TreeView.wItems collection provides access to individual tree view items. This collection holds Win32TreeViewItem objects that correspond to the root tree view items. Each of these Win32TreeViewItem objects, in its turn, has the Items property that contains the collection of child items, and so on. Other properties of the Win32TreeViewItem object let you check and verify the state of the corresponding tree view item, for example, determine if it selected, expanded or collapsed and so on. See Checking Tree View Items' State in Desktop Windows Applications.

Besides standard Win32 tree view controls, TestComplete supports Java Swing and WPF tree views. To work with these controls, it uses the following objects:

  • JTree and JTreeItem -- provide scripting access to Java Swing JTree controls and to individual tree view items, respectively.
  • WPFTreeView and WPFTreeViewItem -- provide scripting access to standard XAML tree views (System.Windows.Controls.TreeView controls) in WPF applications, and to individual tree view items, respectively.

These objects provide methods and properties that are similar to those of the Win32TreeView and Win32TreeViewItem objects. So, you can work with Java Swing and WPF tree view controls in the same way as with standard Win32 tree views. For more information, see Working With Third-Party Tree View Controls in Desktop Windows Applications.

Specifics of Working with TreeView Controls

Recording of actions over tree view controls have the following specific characters:

  • As it was already mentioned, TestComplete records user actions over tree view items using special scripting instructions. For instance, clicks on tree view items are recorded as ClickItem actions, double-clicks - as DblClickItem actions, right-clicks - as ClickItemR actions, and so on.

    Clicks on the “+” and “-” buttons of expandable tree view items are recorded as ExpandItem and CollapseItem actions, respectively.

  • TestComplete records “full paths” to tree view items, that is, paths from the root item rather than paths relative to the current item. In the recorded test, TestComplete usually uses item labels rather that indexes because this makes the test more readable.
  • If the tree view control is owner-drawn, actions over items are recorded using item indexes. See Working With Owner-Drawn Tree View Controls in Desktop Windows Applications.
  • Drag operations are recorded as OnscreenObject.Drag actions using coordinates of the start dragging point and the dragging distance, relative to the tree view control.
  • Recording of actions over tree view item’s check boxes is currently not supported. However, you can successfully record and replay checking and unchecking of check boxes and toggle the item’s state by pressing the Space key rather than clicking on the item’s check box (see Checking and Unchecking Tree View Items in Desktop Windows Applications).

For more information on specifics of test recording in TestComplete, see Recording Specifics.

During playback, the Win32TreeView and Win32TreeViewItem objects use the same principles for simulating user actions over tree view controls:

  • For each method that simulates a click or double-click on a tree view item, you can specify the desired item using its index or label. When specifying the item label, you can use the asterisk wildcard (“*”) to indicate a substring of any length and the question mark wildcard (“?”) to match any single character. See Using Wildcards.

    In addition, methods and properties can treat the item labels 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). For more information, see Addressing Tree View Items in Desktop Windows Applications.

  • If you place a pipeline character ("|") at the beginning of the item path, TestComplete considers the path as relative to the tree root item. Otherwise the item path is considered as relative to the currently selected item.
  • All actions that simulate mouse and keyboard actions (such as Win32TreeView.ClickItem, Win32TreeViewItem.ClickR, OnscreenObject.Keys and others) first activate the window that contains the corresponding tree view control.
  • If the target tree view item is situated out of the visible tree view area, the tree view is automatically scrolled so that the item becomes visible. There is no need to simulate additional actions that would scroll the tree view to the needed item.
  • If the target tree view item is the child item of a collapsed item, the parent item is automatically expanded to reveal the specified item. There is no need to simulate additional actions that would expand the parent item.

See Also

Working With Tree View Controls in Desktop Windows Applications
Working With Owner-Drawn Tree View Controls in Desktop Windows Applications
Working With Third-Party Tree View Controls in Desktop Windows Applications

Highlight search results