Understanding Object Browser

In this recipe we will get familiar with an important TestComplete tool – namely, the Object Browser panel.

The Object Browser panel represents all the processes and objects visible for TestComplete in the system, which are workable from within TestComplete.

Getting ready

We will need to run Calculator Plus as a target application to learn on (C:Program FilesMicrosoft Calculator PlusCalcPlus.exe).

How to do it...

In order to get acquainted with Object Browser we need to perform several steps:

  1. Click on the Object Browser tab in the left part of the TestComplete window (near the Project Workspace pane) or press the following key combination: Ctrl + Alt + O.
  2. In the collapsible list, expand the node Sys, and then the Process ("CalcPlus") node.
  3. In the opened node, click on Window("SciCalc", "Calculator Plus", 1).
  4. On the right-hand panel click on the link View more members (Advanced view):
    How to do it...

How it works...

The Object Browser tab displays all the system nodes within immediate access. On the Objects panel in the left-hand part of the collapsible list, all the system objects are shown. The root node Sys is the main object in the given hierarchy; it is particularly instrumental for accessing all the system nodes.

Sibling nodes of the Sys object are the processes. Each process, in its turn, has child elements, the windows. Also, the main window has child elements, the controls, with which we are working (buttons, data input, lists, toolbars, and others).

Depending on the application type, its complexity, and the customizable settings of the project, this hierarchy may be quite sophisticated. The matter is that TestComplete represents all the application elements, even invisible ones (which are used for positioning controls).

Each item of the Objects tree is an object itself (including the Sys object) with various properties and methods. By default, a short-list view is enabled for the displayed properties. By clicking on the View more members (Advanced view) link we have displayed a complete list without any exceptions.

Properties and methods of the selected item are displayed on the corresponding tabs in the right-hand part of the TestComplete window. Every element has several standard properties always available (such as width, ID, and class); also, the extended properties may be available.

The majority of properties are read-only; however, some of them can be accessed in read-write mode to have them changed. If that's the case, we will see a small circle near the name of the property (for example, the WndCaption property of the main Calculator Plus window). Such properties can be modified from the scripts directly.

Apart from simple properties there are compound properties with values as objects. In this case, in the property-value field, the value of (Object) will be signified. In order to view the value of such property, it is necessary to double-click on its name; this will cause the list to update by displaying properties and methods of the viewed compound property.

For example, double-clicking on the MainMenu property, we will see a list from two properties: the number of child elements and the menu items.

In this example, the Items property is also a compound one, meanwhile this is a property with parameters. Clicking on the Params button, we can have either the index of the menu item assigned or its caption and once more the compound property that corresponds the menu item.

In the process of work (especially, with complex control items), we will be working with Object Browser in order to locate the necessary properties.

There's more...

In the topmost part of the Object Browser panel above the Objects tree, there are several buttons which make it possible to filter the displayed, processed, and other objects. For example, it is possible to hide invisible objects, system processes, and so on; and even selectively display the processes with the help of the filter.

There's more...

The fewer processes and objects displayed on the Objects panel, the faster the information is updated for all the objects in view.

We recommend usage of the Show Tested Applications Only mode when it is possible. If necessary, one can connect, with the help of the filter window, only those processes with which you are currently working.

See also

  • Tested applications are considered in greater detail in the next chapter.
  • If you are unable to find necessary control within the Object Browser tree, read the Using Object Spy recipe.
  • The complexity of object hierarchy may be changed by modifying the Object Tree Model option. The Choosing Object Tree Model recipe in Chapter 5, Accessing Windows, Controls, and Properties, will help you to learn more about it.
  • The following two recipes will give even more useful information on controls and windows:
    • The Understanding how TestComplete interacts with tested applications recipe
    • The Understanding the window's life cycle recipe in Chapter 5, Accessing Windows, Controls, and Properties
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.139.169