Forum Discussion
This is the same question as before. The control I am trying to interact with is this popup menu that appears when you press a dropdown button on a MFC ribbon bar. I cannot interact with the popup menu in the way I need to. I am just simplifying the question a bit to try and figure it out. Before getting into the second popup menu that opens after the first one, I decided to try and get the first popup menu to do something more than a mouse click. There are many methods and properties exposed to TestComplete through MSAA, but so far all the ones I have tried have just given me errors. The only thing that will work so far is the Click method with a X,Y coordinate passed in, and that will simulate a mouse click at those coordinates in that popup window. That is the same as your earlier solution, and is not a complete solution to the problem I am having, as it does not provide the same access I had to this popup menu before we changed to the ribbon interface.
I need to be able to have more interaction with this popup menu than simply clicking on it. The checkmarks in the menu are the only indication to the user that some program features have been activated, and the menu is the only way to activate those features. In order to perform my test completely, I need to ensure the program is in the same state with which options are checked.
Because the menu only appears when you press the dropdown button, and disappears when you click anywhere else, the object browser is useless to me, I cannot go back to TestComplete to refresh the object browser without the window disappearing, and after it disappears the object browser cannot find it. I am able to find the popup menu using Object Spy, as I posted above, using point and fix mode. When I click CTRL-SHIFT-A when the popup menu is highlighted, it will find an object. I have been able to map this object in name mapping the same way, by using Point and Fix mode.
As I said in my previous post, name mapping told me it needed to map the parent object also, and then mapped 2 objects for me. I tried to get screenshots of the Object Spy for those 2 objects to post for you, but evidently it was too big for this forum, and the post never showed up in the thread. There are MANY properties and methods exposed in the advanced view. In the Basic View, the following are exposed:
So far, the only methods that I can make work are Click and ClickR, which will simulate clicking and right clicking in the window. ClickItem looked promising, but always returns the error mentioned in a previous post. FindChild looked like it might be a way to find information about the individual items in the menu, but it also has only returned errors for me.
In this situation, the only way for you to find an object and map in NameMapping is to use Object Spy point and fix mode CTRL-SHIFT-A.
Also when looking at properties you can switch the view from "Basic view" to Advanced by clicking on the link "View more members (Advanced view)", this may help find additional useful properties.
Can Spy identify the check mark as a separate object to map?
- rraghvani2 months ago
Champion Level 3
Sorry for the delay. I've created a WPF application which uses System.Windows.Controls.Ribbon, and have created similar sub menu items with check marks (as shown in your screenshots),
I have mapped the Options button and the three sub menu items like so,
Having the following property values,
I have a simple keyword test that clicks the Options button and then outputs IsChecked property value for each of the sub menu items (I had to use Point and Fix Shift + Ctrl + A with Object Spy tool to recognise the objects),
This generates the following output results,
I had MSAA enabled, but it didn't provided all the properties and methods,
Note the list of properties is short as shown in the Object BrowserI then disabled MSAA, and all properties and methods were then shown in the Object Browser,
Note the list of properties is a lot longer in the Object BrowserClicking the Green menu item,
Try to disable MSAA and UI Automation for *, to see if more properties and methods are shown.
- ErikLarson2 months agoContributor
No. Spy is not recognizing anything below the window level. I mean that it draws the red box around the entire popup menu, and no deeper. I cannot access the items within the popup menu in any way that I have tried. ItemCount returns 0. ChildCount returns 0.
- ErikLarson2 months agoContributor
How were you able to map the RibbonMenuItem objects? They do not show up as mappable objects for me. (they don't get the red box highlight in spy). Did you map them by hand?
- rraghvani2 months ago
Champion Level 3
I just used "Record Keyword Test", then had to use Point and Fix for the sub menu items, as it kept disappearing, while recording, if you hover over the control, TC will eventually highlight the control.
- ErikLarson2 months agoContributor
This looks like exactly what I need.. But I cannot figure out how to do what you did. How were you able to map the Red Green Blue menu items? TestComplete Spy will highlight the whole menu for me, but not the individual items. It also looks like you have one more level in the hierarchy that I am missing
yours:
HWndSource Popup Root->Popup root->Decorator->NonLogicalAdornerDecorator->RibbonMenuItemMine:
RibbonPanelMenu->RibbonPanelMenuBarIt looks like the actual menu is missing from my detection - You have 2 more levels to get to the menu items. So I am guessing I am missing the NonLogicalAdornerDecorator (which should be the actual menu) and the menu items.
The difference might be from yours being WPF and mine being C++ with MFC, but I am not sure.. - rraghvani2 months ago
Champion Level 3
What version of TestComplete are you using?
Is it definitely C++ and MFC, and not .Net?
- ErikLarson2 months agoContributor
I just tried, as you said, to just leave it hovering.. It never highlights the menu items, just the full window with the menu in it.. Screen turned off after 15 minutes of hovering there..