How to check if a menuItem is visible?
I am currently testing a WPF application and getting all menus and submenus.
However, when I use the WPFmenu.Items property, it is giving me all submenus which are not visible on the actual GUI.
Is there a way to check whether a menuItem is visible?
I have checked for Enabled property and it doesn't work as I expect it to.
# menuItem - TestComplete MenuItem Object
# menuObj - User-defined class rssMenu
def getSubMenuRecursive(menuItem,menuObj):
# If a menu, has a submenu get the number of submenus
if (menuItem.SubMenu != None):
subMenuCount = menuItem.SubMenu.Count
# else return, there is nothing to recurse
else:
subMenuCount = 0
# Recurse to find all the linked subMenus
for i in range(subMenuCount):
subMenuItem = menuItem.SubMenu.Items[i]
if (subMenuItem.Enabled == True):
subMenuItemObj = rssMenu(subMenuItem,menuObj)
# I want a submenu to be added to menuObj.submenu[] only when it is visible on the application
if (isVisible(subMenuItem) == True):
subMenuItemObj = getSubMenuRecursive(subMenuItem,subMenuItemObj)
menuObj.addSubMenu(subMenuItemObj)
return menuObj
---------------------------------
# User-defined rssMenu
class rssMenu():
def __init__(self,obj = None,parent = None):
self.name = obj.Caption
self.parent = parent
self.subMenu = []
def addSubMenu(self,obj):
self.subMenu.append(obj)
return