In order for TestComplete to work with individual toolbar buttons in scripts or keyword tests, it needs a way to identify and specify them. For this purpose, TestComplete uses either item captions, indexes (position within the toolbar) or IDs. Captions are more usually preferable than indexes, because they make tests more readable and stable, whereas indexes are less easy to understand and, moreover, they may change during the run. IDs also provide a stable way to identify toolbar buttons, but they are less easy to understand than indexes.
Standard Win32 controls are drawn by the operation system itself. However, Windows also lets applications handle drawing their controls, including toolbars, in a custom way. The controls drawn by the application are called owner-drawn. In general, owner-drawn controls may have no labels and their contents can be arbitrary. To learn whether your tested application owner draws its controls, ask the tested application developers.
If the toolbar is owner-drawn, TestComplete identifies its buttons using IDs. This means that TestComplete records actions with owner-drawn toolbars using button IDs. Since button IDs are constant, their usage ensures the scripts and keyword tests stability. When writing scripts for testing owner-drawn toolbars manually, you should also specify buttons by IDs (see Addressing Toolbar Buttons in Desktop Windows Applications). For example:
|Tip:||To make the test more readable, you can create special constants that will hold the button IDs and use these constants rather than the corresponding numeric values in the property and method calls:
var btnNew = 3802;
Const btnNew = 3802
const btnNew = 3802;
var btnNew = 3802;
This approach also makes it easier to update the test if button IDs in the tested application change in the next application version.
To specify items of owner-drawn toolbars by text, try using the appropriate approaches described in the Object Identification section. For other tips on dealing with non-standard controls, see Ways to Interact With Application Objects.
Working With Toolbars in Desktop Windows Applications
Testing Owner-Drawn Controls
Working With Third-Party Toolbars in Desktop Windows Applications
Addressing Toolbar Buttons in Desktop Windows Applications