Menu Action Operation

Applies to TestComplete 15.40, last modified on March 25, 2022

Description

The Menu Action operation simulates user actions over window menus. Using this operation, you can select or check items from main or system menus of application forms or choose items from the controls’ context menus.

When you add the operation to your keyword test, TestComplete displays the Operation Parameters wizard, where you specify the menu type, the object, to which this menu belongs, the method or property that will perform the test action and the method’s parameters (if needed).

If you are going to simulate user actions on a context menu of a control or window, you must add the operation or operations that make this menu visible. These operations must be before the Menu Action operation in the test. Otherwise the context menu may be hidden by the operations that are between them. If the context menu is invisible, the Menu Action operation will fail.

The easiest way to show a context menu from the test is to use the On-Screen Action operation that will simulate the click of the right mouse button on the desired control, or that will simulate the pressing of the Application key.

Operation Result

The operation does not return any value.

Scripting Analogue

The operation is a keyword test analogue to obtaining the Menu object through the MainMenu, SystemMenu and PopupMenu properties and calling methods of this Menu object.

Child Operations

The operation cannot have child operations.

Operation Parameters

The operation uses the following parameters:

  • The menu type (main menu, system menu or context menu).
  • The window or control, to which the menu belongs.
  • The name of the method or property to be called.
  • The method’s (or property’s) parameters, if any.

When you add the operation to your keyword test, TestComplete displays a wizard that lets you specify all of these parameters. To modify parameters of an operation that is already added to the test, you can use special dialogs and in-place editors provided by the Keyword Test editor. These dialogs and in-place editors are analogues to the wizard’s pages.

Specifying Parameters When Adding the Operation

The wizard, that TestComplete displays when you are adding the operation to your test, contains the following pages:

Choose Menu Type

On this page you specify the type of the menu: main, system or popup.

Select Object

On this page you specify the object to which the desired menu belongs. To specify the object, you can select it on screen, or, if the object is mapped, choose the object’s mapped name or alias. For detailed information, see Selecting Objects for Keyword Test Operations.

Note: If you are going to work with the main or system menu, the selected object must correspond to the application’s form or dialog. If you chose the context menu type, the selected object can be a window or control.
Specify Method or Property

On this page you may select the method or property to be called. TestComplete works with various types of menus through the Menu object. For information about methods and properties displayed on this page, see description of the Menu object.

Operation Parameters

On this page you can specify the parameter values used to call the method or property that was selected on the previous page of the wizard. For information about the parameters, see the method or property description. For information on working with this page and setting the values, see Specifying Parameter Values.

Typically, the methods that simulate the selection of menu items have the Item parameter that specifies the desired item. The item can be specified by its caption, or index in the menu. Indexes begin from 0 and should be enclosed in brackets. Menu separators are counted as items. Indexes can be useful when working with menu items of the MFT_OWNERDRAW or MFT_BITMAP style, as these items may hold no text.

Submenu items should be specified by the “full path” starting from the top-level menu. To separate items in the “path”, use the vertical character (“ | ”).

Below are some examples of specifying the Item parameter value:

View|Show Toolbar
[3]|[1]
View|[1]

If you specify the item by the caption, TestComplete can treat it as case-sensitive or case-insensitive according to the Use case-sensitive parameters project property. You can use wildcards (* and ?) in the item caption, where the asterisk corresponds to a string of any length and the question mark - to any single character.

The item caption should not include the special character that is used to create an access key for that item. To specify the access key, developers typically insert the ampersand symbol before the desired character in the item name. So, the ampersand is one of these special characters. Another special character is an underscore. It is used to specify access keys for WPF menu items. So, if you are working with WPF menus, you should specify item names that do not include these “special” underscores. Typically, only the first found ampersand or underscore symbol is treated as a special character. All other ampersands and underscores are treated as ordinary characters.

Modifying Parameters

After adding the operation to the test, you can modify the operation parameters with the same wizard that you used to add the operation. To invoke the wizard, simply double-click the operation’s row in the Keyword Test editor.

To modify parameters of the operation, you can also use the in-place editors and dialogs provided by the Keyword Test editor.

To change the menu type:

  • Select the operation in the test.

  • Click within the Item cell twice (not a double-click), or select the cell and press F2. This will activate the in-place editor.

  • Click the ellipsis of the in-place editor. This will invoke the first page of the Operation Parameters wizard, in which you choose another menu type.

  • Choose the desired menu type and click Finish to close the wizard.

  • Press Enter to apply the changes and close the in-place editor. Press Esc to discard the changes.

To select another object:

  • Select the operation in the test.

  • Click within the Item cell twice (not a double-click), or select the cell and press F2. This will activate the in-place editor.

  • Click the ellipsis of the in-place editor. This will invoke the Operation Parameters wizard, which TestComplete displayed when you were adding the operation to the test.

  • In the wizard, click Next to activate the Select Object page and then choose the desired object on this page.

  • Click Finish to close the wizard.

  • Press Enter to apply the changes and close the in-place editor. Press Esc to discard the changes.

To select another method or property:

  • Select the operation in the test.

  • Click within the Operation cell twice (not a double-click), or select the cell and press F2. This will activate the in-place editor.

  • Choose the desired method from the drop-down list of the in-place editor.

  • Press Enter to apply the changes and close the in-place editor. Press Esc to discard the changes.

To specify the method or property parameters:

  • Select the operation in the test.

  • Click within the Value cell twice (not a double-click), or select the cell and press F2. This will activate the in-place editor.

  • Click the ellipsis button of the in-place editor. This will invoke the Operation Parameters dialog, in which you can specify the parameters. For detailed information on the parameters, see the description of the method or property, to which the parameters belong.

  • Click OK in the dialog to save the changes.

  • Press Enter to apply the changes and close the in-place editor. Press Esc to discard the changes.

Remarks

When you add the operation to a test, TestComplete also appends grouping nodes that correspond to the window or control, to which the specified menu belongs.

See Also

Test Actions Category
Specifying Operation Parameters
Selecting Objects for Keyword Test Operations
Checking Operation Result
Simulating Menu Actions

Highlight search results