TestComplete can record and play back user actions over various kinds of window menus – main, system as well as context (popup) menus. It simulates actions on menu controls using various methods of the
Menu object –
Menu.Check, and others. The
Menu object is used to work with menus of any type: main, system or context as well as submenus.
To provide access to window menus, each window object contains the
PopupMenu properties. Each of these properties returns a
Menu object that provides a scripting interface to the appropriate menu.
Besides standard Win32 menus, TestComplete supports menus implemented using third-party menu components by Microsoft, Borland and other popular vendors. To access such menus, TestComplete provides special properties that should be used instead of
PopupMenu, for instance,
StripPopupMenu and others. All of these properties, except for
XtraPopupMenu, return the
Menu object as well, so that you can work with custom menus in the same way as with standard Win32 menus. The
XtraPopupMenu property returns the
XtraPopupMenu object whose functionality is similar to the
Menu object's functionality.
For more information, see Working With Third-Party Menus.
|In order for TestComplete to access a context (pop-up) menu, the menu must be displayed on the screen first. Otherwise, an error will occur. To invoke the context menu, you can simulate either a right-click over the window or control, or the Application keypress. See the Displaying Context Menus topic for details.|
To access individual menu items, the
Menu object provides the
Items property that returns a
MenuItem object. Using various properties of this object, you can check and verify the menu item state, for example, determine if it is checked or unchecked, enabled or disabled and so on. See Checking Menu Item's State.
Recording of user actions over menu controls has the following specifics:
When recording actions over menus, TestComplete can identify menu items by their captions or indexes (see Addressing Menu Items). Usually, TestComplete uses item captions in the recorded test, because this makes the recorded test more readable.
However, owner-drawn and bitmap menu items may have no caption. To create a stable test, when recording actions over such menu items, TestComplete uses the item indexes. See also Working With Owner-Drawn and Bitmap Menus.
Some applications implement menus using toolbar controls. For instance, the main menu of Windows Explorer is actually a Win32 toolbar control. For such windows, either the
MainMenu property is null or the
Menu.Countproperty is zero. To simulate user actions on menus implemented using toolbar controls, TestComplete uses methods and properties of the
When recording actions over such menus, you should not use the “auto-open” menu feature. That is, you should click on each item you wish to open, even if the submenu automatically opens upon hot-tracking the menu item. Otherwise, the recorded test may be incorrect. For more information on this, see Recording Specifics.
For Java AWT: You may face an issue when TestComplete cannot record actions with menus of the
java.awt.PopupMenu class. For a detailed description and more information on how to resolve the issue, see Troubleshooting Java Applications.
During the playback, TestComplete uses the following principles of simulating user actions on the menu controls:
In order to recognize a menu during the test run, TestComplete hovers the mouse pointer over the center of the menu control before it can simulate user actions on the menu. Though this behavior should not interfere with the test run, keep in mind that it can invoke the drop-down items or submenus of the menu item residing at the center of the menu.