Forum Discussion

sudhir_optima's avatar
sudhir_optima
Contributor
13 years ago

How to click sub menu item

We have written a function to click a Menu item as



function (ColumnName,PopupMenupath)

{

grid.clickColumnHeader(ColumnName,20,9,2);

grid.popupmenu.Click(PopupMenupath);

}



It works for Menu Item (PopupMenupath) who does not have sub menu. But in our my Menu some has sub menu items.



So how to make above function as generic so that it work for both menu items who has sub menu item too.
  • Hi Sudhir,



    Your popmenu path can be 'New|Folder' when you have sub-menu items. Test-complete supports this feature.



    Hope this would help-out to resolve your issue.
  • No Deva, it still not working



    My Menu has 10 items. Of which 9th item has sub menu. I am calling thhis function by passing the column name and index as 9|2

    ( i.e. Second sub menu ittm of 9th parent item)



    But it is clicking 4 item.
  • Sudhir,



    Please clarify,

    Have you used spy objects to identify the index of an item?

    Why dont you try with Strings rather than caption?



    If you have not used an object spy and given index based on the order it present, may be its different order that testcomplete recognize.

  • Hi Sudhir,



    I am guessing that you have a VCL application (e.g. Delphi) with controls from Developer Express. Please let me know if I am wrong.



    Most probably, the menu in your application is owner-drawn. In this case, you need to address the needed item by its index in this way:

    ...

      var PopupMenupath = "[8]|[1]";

      clickItem(ColumnName,PopupMenupath);

    ...

    function clickItem(ColumnName,PopupMenupath)

    {

      grid.clickColumnHeader(ColumnName,20,9,2);

      grid.popupmenu.Click(PopupMenupath);

    }