Accessing Sub Menu Items from Context Menu
This is my first question to the community. I'm testing a WPF app with TC v12.60 and trying to access sub menu items from a context menu generated from a right-click on an object.
The context menus are as follows:
- ContextMenu_Item1
- ContextMenu_Item2
- SubMenu1_Item1
- SubMenu2_Item1
- SubMenu2_Item2
- SubMenu_Item2
- SubMenu1_Item1
- etc.
The object that gets the right-click is in a ListView. I generate the right click as follows:
Aliases.MyApp.HwndSource_mainWindow.mainWindow.tabControl1.listBoxDevices.ClickItemR(0)
I then access the contextmenu as follows:
contextmenu = Aliases.CrewWare.HwndSource_PopupRoot.PopupRoot
I can navigate the submenus as follows:
# Hover mouse over a menu item at X,Y coordinate
contextmenu.HoverMouse(60, 100)
Delay(500)
#Submenu1
mouseX = Sys.Desktop.MouseX
mouseY = Sys.Desktop.MouseY
mouseX = mouseX + contextmenu.Width
submenu1 = Sys.ObjectFromPoint(mouseX, mouseY)
objectPoint = submenu1.ScreenToWindow(mouseX, mouseY)
submenu1.HoverMouse(objectPoint.X, objectPoint.Y)
Delay(500)
#Submenu2
mouseX = Sys.Desktop.MouseX
mouseY = Sys.Desktop.MouseY
mouseX = mouseX + submenu1.Width
submenu2 = Sys.ObjectFromPoint(mouseX, mouseY)
objectPoint = submenu2.ScreenToWindow(mouseX, mouseY)
Delay(500)
submenu2.Click(objectPoint.X, objectPoint.Y)
This all works to click the menus, but I really want to access the menus by name instead of X,Y coordinates. What is the best way to access the menu items by Header name or even by WPF Object name?