Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How to work with right-click context/popup menus in SilkTest?

How to work with right-click context/popup menus in SilkTest?

An alternative to using coordinates to specify where SilkTest should click on a menu item in a context/popup menu is to use the GetItemRect() function to get the coordinates of the context/popup menu, then call PopupSelect() to select a menu item.

A drawback of this is that to use the GetItemRect() function, we need the Classic Agent, therefore, if the application under test is required to be tested using the Open Agent, we have to record the windows declaration of the application using the Classic Agent also. As we only need the windows declaration for the actions we wish to perform on the context/popup menu, we can record actions to generate this declaration.


Once the Classic Agent declarations are complete, we can then revert back to the Open Agent to continue our tests. Purpose of the windows declaration for the Classic Agent is to allow SilkTest to handle the actions we wish to perform that require Classic Agent only functions.

Example:

--------------------

We will test against the Computer Manager (MMC) application in Windows. The following testcase navigates to the "Removable storage" treenode, then right-clicks on the treenode item and from the context/popup menu, we select "Properties". The Open Agent window declaration is what we use to perform the intial actions of navigating the treeview object. Then using the Classic Agent declarations, we can call the GetItemRect() function as shown below.


Open Agent declaration:

window MainWin ComputerManagement
multitag TAG_IS_OPEN_AGENT
"Computer Management"

// The working directory of the application when it is invoked
const sDir = "C:\"
.....

.....

Classic Agent declaration (recorded only from actions performed on the treeview node object):

window DialogBox ComputerManagement1
tag "Computer Management"
window ChildWin ComputerManagementLocalSt
tag "Computer Management (Local)\Storage\Removable Storage"
parent ComputerManagement1
CustomWin MMCViewWindow1
multitag "[MMCViewWindow]#1"
"$59648"
TreeView TreeView1
multitag "#1"
"$12785"

Testcase to perform required actions:

testcase TreeView()
// declare variable to be used in the testcase
WINDOW wTree = ComputerManagement.Control1.ComputerManagementLocalSt.Control1.TreeView1 // TreeView object
STRING sNode = "/Computer Management (Local)/Storage"
STRING sTreeNode = "/Computer Management (Local)/Storage/Removable Storage"
STRING sMenuItem = "Properties"
RECT iRect

ComputerManagement.SetActive()
// expand necessary treenode
wTree.Expand(sNode)
sleep(
1)
// select the treenode
wTree.Select(sTreeNode)
sleep(
1)
// right-click using the keyboard context menu key
wTree.TypeKeys(
"")
sleep(
1)

// recorded declaration with classic agent
// use RECT data type to get screen position of the
context/popup menu
iRect = ComputerManagementLocalSt.MMCViewWindow1.TreeView1.GetItemRect(sTreeNode)
// focusing on the screen position retrieved from iRect, click on the menuitem
ComputerManagementLocalSt.MMCViewWindow1.TreeView1.PopupSelect(iRect.xPos, iRect.yPos, sMenuItem)

* The testscript will be run using the Open Agent, but Silktest will know when a Classic Agent declaration is in use and will revert to the Classic Agent when required and vice versa.


Related documents:

Old KB# 23635

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:37
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.