Forum Discussion

tyingst's avatar
tyingst
New Contributor
14 years ago

WaitChild method, syntax and how does it work?

I have an application that pops up a dialog with an unpredictable number of lines of text. 



The application expects the user to read each line of text -- and does so by making sure the user hits the down-arrow for every text entry.

When the lines of text are exhausted, a button is displayed at the bottom of the dialog -- the user needs to select that button to continue.



My plan was to use code like:





     while not Aliases.TMDS.frmSingleFormAuthorityCP.gbTNT.btnRepeatTNT.WaitChild("btnRepeatTNT", 1000).Exists

        Call Aliases.TMDS.FrmSingleFormAuthorityCP.gbTNT.Keys("[Down]")

     wend

     Call Aliases.TMDS.frmSingleFormAuthorityCP.gbTNT.btnRepeatTNT.ClickButton



However, when executing the script, the button pops up, but I never exit the while/wend loop -- it just keeps on down-arrowing ad-infinitum.



The "btnRepeatTNT" object is a child of the .gbTNT. object.





What am I doing wrong?


  • Hi,



    Actually, WaitChild won't work with mapped objects. You need to use the WaitAliasChild method:



    Set obj = Aliases.TMDS.frmSingleFormAuthorityCP.gbTNT



    While not obj.WaitAliasChild("btnRepeatTNT", 1000).Exists

    Call obj.Keys("[Down]")

    Wend



    Call obj.btnRepeatTNT.ClickButton


  • I think your problem is not re-evaluating the object after the key press down.



    What happens is that when you evaluate the expression [Aliases.TMDS.frmSingleFormAuthorityCP.gbTNT.btnRepeatTNT.WaitChild("btnRepeatTNT", 1000).Exists ] TC returns a stub object (similar to other wait methods, see for example WaitWindow)with Exists = False

    After that, the object never gets refreshed to check if now the object does in fact exist



    I would add a line this way:

    while not Aliases.TMDS.frmSingleFormAuthorityCP.gbTNT.btnRepeatTNT.WaitChild("btnRepeatTNT", 1000).Exists

            Call Aliases.TMDS.FrmSingleFormAuthorityCP.gbTNT.Keys("[Down]")

            Call Aliases.TMDS.frmSingleFormAuthorityCP.gbTNT.btnRepeatTNT.WaitChild("btnRepeatTNT", 1000)

    wend

    Call Aliases.TMDS.frmSingleFormAuthorityCP.gbTNT.btnRepeatTNT.ClickButton



    Help this helps.