Forum Discussion

Yshvets's avatar
Yshvets
Occasional Contributor
13 years ago

How to exit the "While Not" loop

Hi,



I have the following "While Not" in place which is working like a clock. I would like to add an additional logic to exit the loop after X amount of tries (In case the button never becomes available)






While Not Aliases.sys.IEXPLORE.pageEcommittingLogin.buttonContinue.Exists


..IEXPLORE.pageEcommittingLogin.buttonContinue.Exists

aqUtils.Delay 1000 ' 1 sec delay



Wend



Call Aliases.sys.IEXPLORE.pageEcommittingLogin.buttonContinue.Click





Thank you for the help in advance!

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Why not use the WaitAliasChild in an "if then" statement and have it simply break out on an error?  Something like



    if Not Aliases.sys.IEXPLORE.pageEcommittingLogin.WaitAliasChild("buttonContinue", 10000).Exists 


    then Log.Error("didn't work")



    else 

    Call Aliases.sys.IEXPLORE.pageEcommittingLogin.buttonContinue.Click


    endIf



    Sorry if my syntax is bad... essentially, the above will wait 10 seconds and then return false if it doesn't exist or true if it does.  Varying the number varies the length of time you wait... so, effectively, this is the same as putting a counter in your "While" loop to loop X number of times, delaying 1 second each...
  • Yshvets's avatar
    Yshvets
    Occasional Contributor
    Hi Robert,



    Thank you very much for your response. I was wondering if i could ask you for another advice. There is a web page where i need to select products (total 8 of them) and then proceed to the next page and select dates (4 of them) based on which i can export a file (*.csv) and save it on a hard disk. Currently i have my script broken down into 8 subs. Each sub executes steps per product. If there a way to create a loop for this flow and then exit somehow once last product routine is done? Could you please suggest which loop i need to use?



    Please see the example below:



    Webpage1 "Pick a product"  and proceed to Webpage2"

    P1

    P2

    P3



    Webpage2 "Pick a date" - 4 dropdowns. Dates are always consistent (30, 45, 60, 75)

    run the query and export the file



    Thank you very much for your help.


  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    First of all, it's good practice to start a new thread for a new question rather than "piggybacking" as it will make it easier for others to find answers if they search in the future.



    As for what you're asking, I'd suggest you investigate using a DDT loop where there's an external file that lists your products.  then, you'd run a while loop on the DDT object until the you reach the end of the file.  That while loop would contain your steps  in your several sub-routines.