Good afternoon,
I have a menu which has child menus that I have already built a functio work with. I now need to go 1 more level deep. Below is the code for the function and the calling code. I need some help on line 183 which is the last code to get the 3rd level menu.
Menu / Item 1 works with existing funciton
Menu / Item 1 / SubItem 1 I cannot get past the error on line 183 see code below.
Regards,
Brian
Set objectMainPage = SwfWindow("Summit FT - Bond Definition")
'Process the selection of Bond Definiton, Analytics, Details... from the menu'Build up the menu code here to select from the menusSet objectToolBar =objectMainPage.SwfToolbar("_toolbarsDockAreaTop")specifiedToolBar = "Desktop Menu"specfiiedToolBarMenuItem = "Bond Definition" 'This is what the text that you see is without the shortcut keybonspecifiedToolBarSubMenu = "Validate" 'Text is case sensitivespecifiedToolBarSubSubMenu = "Details..." 'Text is case sensitivenameToolBar = "" 'Toolbar namenameToolBarMenu = "" 'Toolbar main menu itemnameToolBarMenuSubMenu = "" 'The submenu namenameToolBarMenuSubSubMenu = "" 'The submenu nameobjectToolBarSubSubmenu = "" 'The object to recieve the subsubmenu object for validation of enabled etc properties in the calling scriptreporterDetailsFuncSelectToolBar = ""'Get the toolbar text/name with the toolbarbutton text/nameeventCodeFuncSelectToolBarMenu = CommonTMSSelectToolBarMenuItemTwoLevels(objectToolBar, specifiedToolBar, specfiiedToolBarMenuItem, specifiedToolBarSubMenu, specifiedToolBarSubSubMenu, nameToolBar, nameTBarItem, nameToolBarMenuSubMenu, nameToolBarMenuSubSubMenu, objectToolBarSubSubmenu, reporterDetailsFuncSelectToolBar)If eventCodeFuncSelectToolBarMenu = 0 Then 'Click on the menu item by opening the dropdown and then selecting the submenu objectToolBar.DropdownToolbarTool specifiedToolBar,nameTBarItem 'Click the submenu item right afterwards or it will not work ***No Steping Though This one 'DropdownMenuTool "Desktop Menu,186:EntityView","197:Analytics" objectToolBar.DropdownMenuTool nameToolBar & "," & nameTBarItem, nameToolBarMenuSubMenu 'Click the subsubmenu item right afterwards or it will not work ***No Steping Though This one 'ClickMenuTool "Desktop Menu,186:EntityView,197:Analytics","208:Detail" objectToolBar.ClickMenuTool nameToolBar & "," & nameTBarItem, nameToolBarMenuSubSubMenu 'Check if the tab for the main page has the Asset Details TabElse eventCode = 1 eventLoopCode = 1 reporterDetails = reporterDetails & reporterDetailsFuncSelectToolBarEnd If
' @Function Name CommonTMSSelectToolBarMenuItemTwoLevels' @Description Select the submenu item from the menu item. We are matching based on the text displayed for the menu item not the recorded values' *******NOTE: you will need to get the toolbar name by recording the selection of a buttom and getting the toolbar name' *****************Example' SwfWindow("Summit FT - Calendar Definition").SwfToolbar("_toolbarsDockAreaTop").DropdownToolbarTool "Desktop Menu","57:EntityView" 'DropdownMenuTool "Desktop Menu,186:EntityView","197:Analytics" 'ClickMenuTool "Desktop Menu,186:EntityView,197:Analytics","208:Detail"' Toolbar = "Desktop Menu"'ToolbarMenu= "EntityView" ++++++++++++ We have replaced the compare based on the visible text to the user instead of the Key which is EntityView' ToolbarSubMenu = "Open"
'********************Menu Submenu Selection' Example if nameTBarMenu = "File" & nameTBarSubMenu "Open" we will open the dropdown Menu for File and then select the submenu Open item' @Documentation <objectPageToolBar> the toolbar control in the object repository for the page' @Documentation <nameSpecifiedToolBar> the name of the toolbar to find' @Documentation <nameSpecifiedToolBarButton> the name of the toolbar button to find' Returns:' <nameTBar> the toolbar text/name for selecting the button' <nameTBarItem> the toolbar button text/name for selecting the button' <objectTBarSubMenu> the menu object found for use in the calling script to check enabled and other status.' <resultDetails> the details regarding the function' <resultCode> the result code for pass or fail' Otherwise, the value of the NoData environment valueJim' Created: 04/25/2011 BLW' Last Updated:Function CommonTMSSelectToolBarMenuItemTwoLevels(byVal objectPageToolBar, byVal nameSpecifiedToolBar, byRef nameSpecifiedToolBarMenu, ByRef nameSpecifiedToolBarSubMenu, ByRef nameSpecifiedToolBarSubSubMenu, byRef nameTBar, byRef nameTBarMenu, byRef nameTBarSubMenu, byRef nameTBarSubSubMenu, ByRef objectTBarSubSubMenu, byRef resultDetails)' &&&&&&&&&&&& Note the values in the menu and compares are text and Case Senseitive. please insure you send in the value to match the menu item resultCode = 2 countToolBar = 0 booleanToolBarFound = False booleanToolBarMenuFound = False booleanToolBarSubMenuFound = False booleanToolBarSubSubMenuFound = False objectTBarManager = "" 'Temp destroy on exit objectTBar = "" 'Temp destroy on exit 'Set the toolbar manager based on the control from the page Set objectTBarManager = objectPageToolBar.Object.ToolbarsManager.Toolbars countToolBar = objectTBarManager.Count If countToolBar > 0Then For loopToolbars = 0 to countToolBar - 1 nameTBar = Trim(objectTBarManager.GetItem(loopToolbars).Key) If nameTBar = nameSpecifiedToolBar Then Set objectTBar = objectTBarManager.GetItem(loopToolbars) booleanToolBarFound = True Exit For End If Next If booleanToolBarFound = False Then resultCode = 1 resultDetails = resultDetails & " WE DID NOT FIND toolbar of: " & nameSpecifiedToolBar & " WE CANNOT SEARCH FOR THE MENU." End If Else resultCode = 1 resultDetails = resultDetails & " WE DID NOT FIND ANY TOOLBARS." End If 'Start looking for the menu if the assigned toolbar was found If booleanToolBarFound = True Then 'See if we can get the menu next countToolBarMenus = objectTBar.Tools.Count If countToolBarMenus > 0 Then 'Check the button and see if we can find the one we specified For loopMenus = 0 to countToolBarMenus -1 inStringToolName= "" textTBarItem = "" nameTBarMenu = objectTBar.Tools.GetItem(loopMenus).Key textTBarMenu = CStr(objectTBar.Tools.GetItem(loopMenus).CaptionResolved) stringHotKey ="&" 'Strip out the & key for the hotkey in the menu item instringLoc = InStr(1, textTBarMenu, stringHotKey) lenString = Len(textTBarMenu) tempStringLeft = "" tempStringRight = "" Select Case instringLoc Case 0 'Do nothing there is no hotkey specified for this item Case 1 'Remove the & from the front of the text textTBarMenu = Right(textTBarMenu, lenString - instringLoc) Case Else 'Build the string by gettting what is left of the & and then what is right of the & tempStringLeft = Left(textTBarMenu,instringLoc - 1) tempStringRight = Right(textTBarMenu, lenString - instringLoc) textTBarMenu = tempStringLeft & tempStringRight End Select 'Check if the displayed text matches the requrested menu item If textTBarMenu = nameSpecifiedToolBarMenu Then booleanToolBarMenuFound = True Set objectTBarMenu = objectTBar.Tools.GetItem(loopMenus) Exit For End If Next If booleanToolBarMenuFound = False Then resultCode = 1 resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " BUTthe menu item of: " & nameSpecifiedToolBarMenu & " was not found." End If Else resultCode = 1 resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " BUT NO MENUS WERE FOUND." End If End If 'Tool Bar found and looking for the menu 'Start Looking for the submenu item if menu found If booleanToolBarMenuFound = True Then 'See if the menu item has any submenu items countToolBarSubMenus = objectTBarMenu.Tools.Count If countToolBarSubMenus > 0 Then 'Check the button and see if we can find the one we specified For loopSubMenus = 0 to countToolBarSubMenus -1 nameTBarSubMenu = objectTBarMenu.Tools.GetItem(loopSubMenus).Key textTBarSubMenu = CStr(objectTBarMenu.Tools.GetItem(loopSubMenus).CaptionResolved) stringHotKey ="&" 'Strip out the & key for the hotkey in the menu item instringLoc = InStr(1, textTBarSubMenu, stringHotKey) lenString = Len(textTBarSubMenu) tempStringLeft = "" tempStringRight = "" 'Use case statement here to work with 0, 1, or else Select Case instringLoc Case 0 'Do nothing there is no hotkey Case 1 'Remove the & from the front of the text textTBarSubMenu = Right(textTBarSubMenu, lenString - instringLoc) Case Else 'Build the string by gettting what is left of the & and then what is right of the & tempStringLeft = Left(textTBarSubMenu,instringLoc - 1) tempStringRight = Right(textTBarSubMenu, lenString - instringLoc) textTBarSubMenu = tempStringLeft & tempStringRight End Select ''Check if the displayed text matches the requrested submenu item If Cstr(trim(textTBarSubMenu)) = Cstr(trim(nameSpecifiedToolBarSubMenu)) Then Set objectTBarSubMenu = objectTBarMenu.Tools.GetItem(loopSubMenus) 'Set the object only if correct object is found booleanToolBarSubMenuFound = True Exit For End If Next If booleanToolBarSubMenuFound = False Then resultCode = 1 resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " the toolbar contained the menu of: " & nameSpecifiedToolBarMenu &_ " BUT the submenu of: " & namespecifiedToolBarSubMenu & " WAS NOT DISPLAYED. " End If Else resultCode = 1 resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " the toolbar contained the menu of: " & nameSpecifiedToolBarMenu &_ "however, NO SUBMENU ITEMS WERE AVAILABLE." End If End If 'Start Looking for the SubSubMenu if we found the SubMenu item If booleanToolBarSubMenuFound = True Then 'See if the menu item has any submenu items countToolBarSubSubMenus = objectTBarSubMenu.Tools.Count 'Error Object doesn't support this property or method: 'objectTBarSubMenu.Tools' Line (183): "countToolBarSubSubMenus = objectTBarSubMenu.Tools.Count". If countToolBarSubSubMenus > 0 Then 'Check the button and see if we can find the one we specified For loopSubSubMenus = 0 to countToolBarSubSubMenus -1 nameTBarSubSubMenu = objectTBarSubMenu.Tools.GetItem(loopSubSubMenus).Key textTBarSubSubMenu = CStr(objectTBarSubMenu.Tools.GetItem(loopSubSubMenus).CaptionResolved) stringHotKey ="&" 'Strip out the & key for the hotkey in the menu item instringLoc = InStr(1, textTBarSubMenu, stringHotKey) lenString = Len(textTBarSubMenu) tempStringLeft = "" tempStringRight = "" 'Use case statement here to work with 0, 1, or else Select Case instringLoc Case 0 'Do nothing there is no hotkey Case 1 'Remove the & from the front of the text textTBarSubSubMenu = Right(textTBarSubSubMenu, lenString - instringLoc) Case Else 'Build the string by gettting what is left of the & and then what is right of the & tempStringLeft = Left(textTBarSubSubMenu,instringLoc - 1) tempStringRight = Right(textTBarSubSubMenu, lenString - instringLoc) textTBarSubSubMenu = tempStringLeft & tempStringRight End Select ''Check if the displayed text matches the requrested submenu item If Cstr(trim(textTBarSubSubMenu)) = Cstr(trim(nameSpecifiedToolBarSubSubMenu)) Then Set objectTBarSubSubMenu = objectTBarSubMenu.Tools.GetItem(loopSubSubMenus) 'Set the object only if correct object is found booleanToolBarSubSubMenuFound = True Exit For End If Next If booleanToolBarSubSubMenuFound = True Then 'Report we found the submenu item resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " the toolbar contained the menu of: " & nameSpecifiedToolBarMenu &_ "and the submenu of: " & namespecifiedToolBarSubMenu & " but the sub submenu of: " & nameSpecifiedToolBarSubSubMenu & " WAS DISPLAYED. " Else resultCode = 1 resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " the toolbar contained the menu of: " & nameSpecifiedToolBarMenu &_ "and the submenu of: " & namespecifiedToolBarSubMenu & " but the sub submenu of: " & nameSpecifiedToolBarSubSubMenu & " WAS NOT DISPLAYED. " End If Else resultCode = 1 resultDetails = resultDetails & " We found the toolbar of: " & nameSpecifiedToolBar & " the toolbar contained the menu of: " & nameSpecifiedToolBarMenu &_ "and the submenu of: " & namespecifiedToolBarSubMenu & "however, NO SUB SUBMENU ITEMS WERE AVAILABLE." End If End If
Set objectTBarManager = Nothing 'Temp destroy on exit Set objectTBar = Nothing 'Temp destroy on exit Set objectTBarMenu = Nothing 'Temp destroy on exit CommonTMSSelectToolBarMenuItemTwoLevels = resultCodeEnd Function
It's hard to say specifically what's wrong with it by looking at the code. But what I can say is, likely the Tool it's interacting with at that moment is not what you believe it is, either it's null, a tool that doesn't have subtools, or is merged from a parent mdi toolbar, and therefore is just a placeholder tool, that you need to look at the UnderlyingTool property to interact with it. Start with eliminating the excess. When it hits the error at that line, look at the values of all the pertinent local variables, to get your bearings of is it where you believe it is, and is the tool you are interacting with is the type of tool that you expected.
Hi Michael,
I do not really follow what you are saying here. The function has gotten rather large just to get the the toolbar, menu, submenu items. This code works and allows me to select the sub menu when I need to . Unfortunately the submenu of the submenu is a different issue. I think the issue may be in line 164 where I have found the submenu item and I set the object so I can start looking for the next level down.
Set objectTBarSubMenu = objectTBarMenu.Tools.GetItem(loopSubMenus) 'Set the object only if correct object is found
The above line sets the submenu. I then need to find out how to get the next set of menu items.
Here is the recorded code for the click. It will work only until I restart the application or at best on just my machine due to the dynamic nature of the menus.
SwfWindow("Summit FT - Bond Definition").SwfToolbar("_toolbarsDockAreaTop").DropdownToolbarTool "Desktop Menu","50:EntityView"SwfWindow("Summit FT - Bond Definition").SwfToolbar("_toolbarsDockAreaTop").DropdownMenuTool "Desktop Menu,50:EntityView","78:Maintenance"SwfWindow("Summit FT - Bond Definition").SwfToolbar("_toolbarsDockAreaTop").ClickMenuTool "Desktop Menu,50:EntityView,78:Maintenance","79:PastReset"
As far as debuging the code. I have stepped through all the code to the line which states: If booleanToolBarSubMenuFound = True Then which is the line above 183. The values found are correct. The other issue is of course that we cannot look at the properties of the menu with QTP. What other properties can I set to get the final menu item?
Please let me know if you have any questions or if I should open a ticket on this so we can speak over the phone.
Haï
What was the issue for the question befor ?
I have the same error onD ropdownToolbarTool' "Object doess't support this property or method 'ObjMenu.DropdownToolbarTool Toolbar,Menu1'
Example : ObjMenu.DropdownToolbarTool "Desktop Menu","11:File"
This error produce on windows 7 / 64 bits but does not produce on Windows XP SP3 / 32 bits.
I'm in TA 2011 Vol2 for QTP 11.0
Thanks for your help
Hello,
What patches do you have installed for QTP?
Make sure you have QTP_00116 as this is needed for 64 bit testing. Also if your application under test is targeting .NET 4.0 or you have Windows 7 SP1 installed then you may need to install QTPNET_00116 as that addresses issues with .NET 4.0 and Windows 7 SP1.
Let me know if you have any questions with this matter.
Thanks Alan for your reactivity.
The 64-bit application for QTP11.0 support is explained by HP in this topic. http://support.openview.hp.com/selfsolve/document/KM202273
This KM talking only about QTP_00699, that i already install (with 2 other PATCHs QTP_00709 + QTP_00925) + One RRV_xx for result viewer.
I do i search in HP Site and did not found any QTP_00116 or QTPNET_00116 to download.
Please where do i can fiund theeses patchs ?
Are they any where on ftp site in your side where i can download them ?
Thanks for your help.
FYI we wil create a CASE for HP to download the QTPNET_00116 HOTFixe.
I'l feed you back if the problem Persist.
Thanks
Hello QTP11_User
I suppose that this forum thread is duplicate with https://es.infragistics.com/community/forums/f/test-automation-for-micro-focus-uft-wpf/78818/qtp11-does-not-record-the-menu-actions/398297#398297 . To be easy to follow your request, please write in your own thread https://es.infragistics.com/community/forums/f/test-automation-for-micro-focus-uft-wpf/78818/qtp11-does-not-record-the-menu-actions/398297#398297
Let me know if you have any questions
Regards