Forum Discussion

relie's avatar
10 years ago

Wait for drop-down item to populate in a web app

Hello,



I'm testing a web application.



When I choose a value in a drop-down box, the application will populate the other drop-down boxes on the page.



When I run the script it fails because the value it needs to click does not yet exists in the drop down box.



I tried to add a WaitProperty instruction, but I can't find a way to specify it.



I believe that I've been able to set a wait on the drop-down itself, but the drop-down already exists on the screen, it's just empty.  I need to wait until the CONTENTS of the drop-down appears.



Any hints appreciated.



Thanks !

2 Replies

  • You could try looping around checking that the value exists in the property wItemList (assuming you are not using an interesting combo box from Sencha).



    For example:



    while inStr(myCombo.wItemList, "Value I am looking for") = 0

        aqUtils.Delay 1000

    wend
  • Which is fine.



    But I would add a timeout as a second way to exit that loop.



    Any loop which has the potential to get stuck in a never ending cycle is not a good idea with automated tests as it'll just sit there forever if the value you expect is not populated to the available list.



    So:



    While([object is not in list] AND [time waited < 10 seconds])

        Look for object in list

        Short delay if not found

    End While



    ... would be a more sensible way to go I think.



    Obviously, you would then need some branching after the loop to determine what should happen next depending on whether the value was found or not.



    I have plenty such functions in my code. My stuff has to run unattended. Often for hours at a time. So getting stuck in a never ending loop would not be good.