Forum Discussion

mfoster711's avatar
mfoster711
Regular Contributor
8 years ago
Solved

Check PopupMenu exists

How do I check if a popup menu exists before I try to interact with it? 

 

The following code works as long as the PopupMenu exists. If it doesn't, I get a run time error on the second line.

 

CurrField.Click x,y
Call CurrField.PopupMenu.Click("Sort|Descending")

I tried adding a check for CurrField.PopupMenu.Exists or CurrField.PopupMenu = Null and both of these cause run time errors also.

  • AlexKaras's avatar
    AlexKaras
    8 years ago

    Hi,

     

    Ah, I see. Property will be of no use for you.

    What you should do in this case:

    1) Open Object Spy in TestComplete and switch it to Point-and-Fix mode;

    2) (Right-)click on the control so that the popup menu is opened;

    3) Hover popup menu with the mouse and wait until it is recognized by Object Spy;

    4) Fix the captured object in the Object Spy (Ctrl-Shift-A shortcut if I remember correctly);

    5) Copy the identification code from Object Spy into your test code, adjust and use accordingly.

     

    (It is a usual thing that popup menu is a separate standalone object that is a child of either tested application process or main window.)

12 Replies

  • Don's avatar
    Don
    Contributor

    There's no way of checking to see if a window exists unless you manually verify all the steps. The pop up windows are something that should be in the design documentation.

     

    You can also see if a window exists by going to a browser and clicking F12 for development mode. Then you would just have to dig through to see if there are any windows and find your matching window if it exists.

     

    This is how I find pop up windows and implement them using the xpath.

    • Don's avatar
      Don
      Contributor

      Sorry I meant to say pop up menu but I accidently put widow. But the logic still applies.

      • mfoster711's avatar
        mfoster711
        Regular Contributor

        I am working with a Desktop application, not a browser.