Forum Discussion

ARAKOTONDRABESA's avatar
ARAKOTONDRABESA
Contributor
14 years ago

Work with Windows PopupMenu in Windows 7 and XP

Hi!

I have to launch many tests with many Windows OS like Windows XP, Windows 7 and Windows Vista. My problem is when I launch my test scenario in Windows 7 or Windows Vista, I don't have the same name of windows menuitem compared windows XP. 



For example:

in Windows XP  we have -> PopupMenu.Click("cut");

in WIndows 7 and Vista  we have ->  PopupMenu.Click("[3]");



Have you a solution to recover the true name of the popup menu item in Windows Vista and Seven but not the index?

thanks for help!
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    That is part of the application in question, not the script code.  In this case, it seems like the difference is between Windows XP and Windows 7 so you'll have to double check the parameter "IsOwnerDrawn" as described in the help topics given.
  • Hi!

    I was trying

    var object = Aliases.MyApplication.MyWindows ;

    Log.Message(object.PopupMenu.Click("ItemIndex").IsOwnerDrawn);



    But IsOwnerDrawn return me anything. Normally this property have to return true or false. Have you another suggestion?

    PS: I can't  explore the popupmenu in the Object Browser because when I move my mousse the popupmenu will close. So have you a property to force open this popmenu (like isDropDownOpen or StayOpen),to explore it?

    thanks




  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Change your code to 



    var object = Aliases.MyApplication.MyWindows ;

    Log.Message(object.PopupMenu.IsOwnerDrawn);




    If the IsOwnerDrawn property exists, it will return a true or false on it.  If it doesn't exist, you might get an actual error as it will fail to find the property.
  • Thanks !that is work! but in Windows 7 or Vista  the property IsOwnerdraw return true, so in the topics, if this property return true I have to work with TestComplete with Indexes.My problem is : I wan't to work with Indexes ,but with Caption...Don't you have any solution?

    thanks a lot 
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    As a non-SmartBear person (I don't work for SmartBear), I can't really say what more there is you can do other than work with the indices.  I haven't played around with ownerdrawn  menus recently so I'm not sure if there is a way of getting the caption from other information.  You might want to consider using what I mentioned above about TextRecognition to see if that will help you.



    Other than readable code, is there any particular reason why you need to use the captions?  Functionally, for the automation, it works the same.  
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Excellent!   I kind of thought TextRecognition might be the way to go with this.  Glad that worked for you! 



    I'm going to toss that in my "tool box" of tricks for next time I need to work with an OwnerDraw. :-)