Unable to select Sub Menu Items...

Ask general questions here.
ramancha
Posts: 3
Joined: Fri Aug 19, 2011 12:59 pm

Unable to select Sub Menu Items...

Post by ramancha » Fri Aug 19, 2011 1:57 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Unable to select Sub Menu Items...

Post by Support Team » Fri Aug 19, 2011 4:06 pm

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
.
Image

ramancha
Posts: 3
Joined: Fri Aug 19, 2011 12:59 pm

Re: Unable to select Sub Menu Items...

Post by ramancha » Tue Aug 23, 2011 6:38 am

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>(); >>>