Forum Discussion

rushikesh's avatar
rushikesh
Contributor
8 years ago

Problem with selection in popup menu

Please refer attached image of popup menu in my testing application.

 

I want to select "Edit Definition.." option from the options. I use code :

Object.PopupMenu.Click("[0]");

This works correctly.

 

Problem is when I want to select "Select Machine..." option from the options.

 

I am using the code :

Object.PopupMenu.Click("[1]");

With above code i am getting error "The menu item 1 is disabled" even though this option is in enabled state.

 

If use code :

Object.PopupMenu.Click( "Select Machine..." );

it works. But what is problem with above code ?

  • Hi,

     

    As others already wrote,

    Object.PopupMenu.Click( "Select Machine..." );

    is much better than

    Object.PopupMenu.Click("[1]");

     

    The reason why the latter did not work for you is because menu item with index 1 is a separator displayed as a grayed line between Edit Definition and Select Machine menu items.

    You should use index value of 2 if you like to select Select Machine menu item by index.

     

     

  • baxatob's avatar
    baxatob
    Community Hero

    Probably the actual menu item with index 1 is hidden (disabled). You should check the source code or may be find something using Object Browser.


  • rushikesh wrote:

     

    If use code :

    Object.PopupMenu.Click( "Select Machine..." );

    it works. But what is problem with above code ?


     

    This is much better code anyway. Your other version is using index numbers. Not good. If they add a new menu item, the index numbers change, and your test is broken. Always better to use as static an identifier as possible for doing things like this. Of course, they could also update the text for it, but it's a much lower probability breaker than an index.

     

    And baxatob could well be right. There may be hidden options. Who knows. Not us without access to the object and it's properties ....

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    As others already wrote,

    Object.PopupMenu.Click( "Select Machine..." );

    is much better than

    Object.PopupMenu.Click("[1]");

     

    The reason why the latter did not work for you is because menu item with index 1 is a separator displayed as a grayed line between Edit Definition and Select Machine menu items.

    You should use index value of 2 if you like to select Select Machine menu item by index.

     

     

  • shankar_r's avatar
    shankar_r
    Community Hero

    What is your AUT technology?. I used to work with JSwing application and it works fine for me.