Page 1 of 1

Unable to select Sub Menu Items...

Posted: Fri Aug 19, 2011 1:57 pm
by ramancha
We have a windows Application with main menu with sub menu items. The problem we are facing is, we are able to spy and work with the main menu items. But we cannot read or spy the sub menu items of the main menu item.
We used instant tracking also to spy the Sub menu items; spy is giving the sub menu items. However in run time Ranorex couldn’t find the submenu item even after the main menu item is focused and sub menu item we want to select is visible.
We also tried to read the “MenuItem” and “RawText” from the main menu item programmatically. Even it is not giving any sub menu items list.

IList<Ranorex.MenuItem> subMenuItems= MainWindow.Instance.MainWindowForm.MenuBar.MenuItemFile.FindDescendants<Ranorex.MenuItem>();
subMenuItems.Count is 0.

IList<RawText> SubMenus = MainWindow.Instance.MainWindowForm.MenuBar.MenuItemFile.FindDescendants<RawText>();
SubMenus.Count is 0;

Please refer the attached document for more information and process we are following.

Currently we are using the key board shortcuts, up and down arrow keys to work with sub menu items as work around.
Please suggest us any way to work with the sub menu items.

Thanks
Santosh Ramancha

Re: Unable to select Sub Menu Items...

Posted: Fri Aug 19, 2011 4:06 pm
by Support Team
ramancha wrote:Please refer the attached document for more information and process we are following.
Sorry, but there is no attached document...

If Ranorex Spy can detect the sub menu items, then this should be able at runtime, too.

Have you tried creating and replaying a recording for selecting sub items?
Do you use multiple thread? Have you set the apartment state for all threads to STA?
Is the Main method of your executable marked with the [STAThread] attribute as described in this section in the Ranorex User Guide?

Regards,
Alex
Ranorex Team

Re: Unable to select Sub Menu Items...

Posted: Tue Aug 23, 2011 6:38 am
by ramancha
Thanks Alex for your reply.

The problem was we used MenuItem.Focus() to open the menu, after opening we tried to read the sub menu items. Which was not working.

Now we changed the code to MenuItem.Click() to open the menu. After clicking on the menu, we are able to read the sub menus of it programatically using the below code.
<<< IList<Ranorex.MenuItem> subMenus = menuItem.FindDescendants<Ranorex.MenuItem>(); >>>