General Notes
TestComplete can record and play back actions over toolbar controls in various kinds of Windows applications - Win32, .NET as well as WPF. It simulates actions over toolbars using methods and properties of special programming objects:
Win32ToolBar
-- Provides a scripting interface to standard Win32 toolbars and .NET ToolBar (System.Windows.Forms.ToolBar) controls.StripToolBar
-- Provides a scripting interface to .NET ToolStrip (System.Windows.Forms.ToolStrip) controls.WPFToolBar
-- Provides scripting access to standard XAML toolbars (System.Windows.Controls.ToolBar controls) in WPF applications.
All of these objects have a similar set of methods and properties. For example, all of them have the ClickItem
action that simulates a click on a specific button, the wButtonCount
property that returns the total number of buttons, the wButtonText
property that returns the button text, and so on. These objects also provide properties that let you determine and verify the state of toolbar buttons, for example, check if a specific button is enabled, pressed, and so on. For more information, see Checking the Toolbar Buttons' State in Desktop Windows Applications.
Besides Win32, .NET and WPF toolbars, TestComplete supports toolbars in Java Swing applications. To work with individual buttons on these toolbars, it uses methods and properties of the JButton
object. TestComplete also provides several techniques that let you effectively work with custom toolbar components. For more information, see Working With Third-Party Toolbars in Desktop Windows Applications.
Specifics of Working with Toolbars
The above-mentioned objects use the same principles for simulating user actions over toolbar controls:
-
All methods that simulate user actions over toolbars (
ClickItem
,DblClickItem
,CheckItem
and others) first activate the window that contain the target toolbar. -
You can specify toolbar buttons by their text labels, indexes of IDs (Win32 toolbars only). When specifying the button text, you can use wildcards (* and ?) or regular expressions. 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.
In addition, methods and properties can treat the 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). For more information, see Addressing Toolbar Buttons in Desktop Windows Applications.
Recording of actions over toolbar controls also have some specific characters:
- As mentioned above, TestComplete records actions over toolbars using special methods (such as
ClickItem
,CheckItem
and others) and identifies toolbar buttons by their text, indexes or IDs (see Addressing Toolbar Buttons in Desktop Windows Applications). Usually, TestComplete uses button text in the recorded test, because this makes the recorded test more readable.However, when recording actions over owner-drawn Win32 toolbars, TestComplete uses button IDs rather than captions. This specific character is due to the fact that buttons on owner-drawn toolbars may have no text, that is why TestComplete uses IDs to create a stable test. For more information, see Working With Owner-Drawn ToolBars in Desktop Windows Applications.
- If a toolbar button is a toggle button (that is, it can be pressed or un-pressed), a click on this button is recorded using the
CheckItem
action rather thanClickItem
.
For more information on specifics of recording in TestComplete, see Recording Specifics.
See Also
Working With Toolbars in Desktop Windows Applications
Win32 ToolBar Support
ToolStrip Support
WPF ToolBar Support
Java Swing Button Support
Working With Owner-Drawn ToolBars in Desktop Windows Applications
Working With Third-Party Toolbars in Desktop Windows Applications