Find Menu Items by name and not by index
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Find Menu Items by name and not by index
Hi,
I am trying to access menu items by names and not by index. For example w.MainMenu.Click("File|Open...") does not work, but w.MainMenu.Click("File|[1]") works fine. Why TestComplete does not recognize SubMenu Items by their names?
Thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What type of menu? There are many. They don't all behave the same.
Web? Desktop? Language used? Class of the control? You don't give much info ....
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sorry...
The tested program is in delphi language and the menu is VCL.Menu.TMainMenu.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah OK.
Hold on. I'm working on a Delphi app at the moment. But I don't have to use any menu bars. It's all tool bars in mine. (There are menu bars there though I think .... I just don't need to use them. Soon find out!)
I'll go have a look ....
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're out of luck I'm afraid.
All the strip menu's are in .NET parts of the application. (it's a mixture of .NET which launches Delphi EXE's - I'm working on testing the Delphi parts)
But my guess would be that the option names WILL be stored as a property somewhere. (Or possibly in the "Fields" info? A couple of Delphi controls have required me to dip in there as no property value was suitable or accurate.) You may need debug info enabled to expose it though. Hard to say without seeing one.
So in other words, you use the area where the option text is stored to work out the index numbers. Then use those calculated numbers to make your selection.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, but I am not sure what you exactly mean...
In Object Browser I'm able to see the MenuItem and it has a name VCLObject('Item_Import')
- but this still doesn't work: w.MainMenu.Click(File|Import|[0]|[0]|[0])
and this is in the additional info:
Items: '', '', '', '', '', '', '', '', '', '', '', ...
Aliases.luks.IDAKTControl
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may need a "helper" routine.
If you want people/your tests to be able to select by name, but you can only select using index numbers, then you need to translate those names into index number within your script.
So send the helper routine a menu object, and the option name to be used. It scans through the child objects of the menu (MenuItem objects in your case by the sound of it). When it finds the desired option, it sends back the child object number (assuming that ties in with it's index number). Or it a returns an error if not found.
If your menu runs several levels deep, you may need to call it recursively adding to your "selection string" as each index number is returned.
If you see what I mean?
