Forum Discussion

Astrid's avatar
Astrid
Occasional Contributor
2 years ago

While loop seems to be ignored when looking for a menu bar

Hello again. I am at the end of the first week of my 2 week trial and I cannot get my test to run successfully. I am trying to click an icon on a menu bar that displays after my application opens. Sometimes it takes a while for the UI to display fully and TestComplete fails before all windows and menus are visible.

I tried to employ a while loop based on an example I found in the documentation. It worked the first time but failed every time when I tried to run the test thereafter. Can anyone tell what I am missing or doing wrong? Images are attached.

TiA - Astrid

  • You're checking the property value of VisibleOnScreen, of the object Main, which probably doesn't exist yet. You want to check if the Object exists first. Also, ensure the name mapping defined for the object is correct too. If Main fails to find, then try it's parent object, Ribbon.

     

    See Waiting for an Object, Process or Window Activation

     

     

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I'm not sure how your object is drawn, but you might have to wait for either,

     

    Aliases.draft

    Aliases.draft.wndAfx

    Aliases.draft.wndAfx.Ribbon

     

    Play around with the Wait methods, and see which one works for you.

     

    You can also do something like this,

    Aliases.draft.wndAfx.WaitAliasChild("Ribbon", 30000);

    Assuming Aliases.draft.wndAfx object exist, WaitAliasChild will wait up to 30 seconds for Ribbon to appear.

    • Astrid's avatar
      Astrid
      Occasional Contributor

      Thank You, rraghvani. "Aliases.draft.wndAfx.Ribbon.WaitVCLNETObject" seems to be the only solution that will work. The test actually succeeded once without having to replace with a similar object.

      I will accept your first suggestion to wait for the parent as the solution to my issue. But now I have another problem that I caused and do not know how to fix. I will ask another question for it. Thank you so much for all of your help!

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You're checking the property value of VisibleOnScreen, of the object Main, which probably doesn't exist yet. You want to check if the Object exists first. Also, ensure the name mapping defined for the object is correct too. If Main fails to find, then try it's parent object, Ribbon.

     

    See Waiting for an Object, Process or Window Activation

     

     

    • Astrid's avatar
      Astrid
      Occasional Contributor

      Thank you much! - It seems that I can use "Aliases.draft.wndAfx.Ribbon.WaitVCLNETObject". Is this correct? - It does not work with Main. The test runs to completion waiting for the Ribbon but I get a warning The "Ribbon" object was replaced with a similar object. I do not know how to fix it. Name mapping image is attached.

      TiA for your help! - Astrid