Ask a Question

how to select the multi level sub menu object

SOLVED
Sreera
Occasional Contributor

how to select the multi level sub menu object

Hi all,

 

Can anybody please help me with the issue? Im stuck at a point selecting submenu within a submenu

 

Our desktop application has below Menu format:

 

 Main Menu

   SubMenu1

   SubMenu2

           SubMenuA

           SubMenuB

   SubMenu3

 

I able to select till SubMenu2. How do I select SubMenuA and SubMenuB?

 

Thanks in Advance

7 REPLIES 7
karkadil
Valued Contributor

The easiest way to find out how to select menu item, is to record your actions and then look at the code.

If you work with custom menu, it will be more difficult and require some skills to convert recorded actions into script code.

shankar_r
Community Hero

If the menu is normal and standard menu then you can click by using below lin.

 

MenubarObject.Click(MainMenu|SubMenu2|SubMenuA);

Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

CFQA
New Contributor

I am approaching a similar issue with web testing.  I like the above answers, and may try them if mine does not work. However, my initial thought of how to handle my similar issue would be to use 'Conditional Mapping' within Name Mapping portion of TestComplete. 

 

Conditional Mapping

 

Hope you find solution that best works for you. 

Sreera
Occasional Contributor

Your approach is working fine when i hardcode the values but while looping Im facing a problem. Then second level has only 4 submenus but on using the Submenu.count() while using for loop, it shows 6 in the count list. Any ideas?

  1. Menu
    1. Submenu1
    2. Submenu2
      1. item1
      2. item2
        1. subitem1
        2. subitem2

In the above scenario, when you get submenu count for Submenu2  it will return 4 as it's direct sub submenu has childs.

 

 


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

Sreera
Occasional Contributor

Shankar,

 

Thanks for the quick reply. Your explanation makes sense if we are taking the count of child items of Submenu2. However in our application we have direct child items instead of child items for child items as in your example.

Below is the scenario in our application. The count for SubMenu5 shows 6 instead of 4. Count for Menu shows 5 though(excluding separators) It is similar to Windows Notepad application but with submenu for submenu.

 

Menu
   Submenu1
   Submenu2
   Submenu3
   Submenu4
   Submenu5
          Option1
          Option2
          Option3
          Option4

 

I am able to select each of the options however "index out of bounds" error is thrown for index 5 and 6 which are not even present.

karkadil
Valued Contributor

If you have already excluded separators, than it is possible that you have hidden menu items. You can navigate the menu using Object Spy (the MainMenu property) and examine every single menu item.

cancel
Showing results for 
Search instead for 
Did you mean: