Micro Focus QTP (UFT) Forums
How to end script in QTP if the Do Until loop goes to infinite. - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: How to end script in QTP if the Do Until loop goes to infinite. (/Thread-How-to-end-script-in-QTP-if-the-Do-Until-loop-goes-to-infinite)



How to end script in QTP if the Do Until loop goes to infinite. - uma87 - 09-29-2011

Hi , Can anyone please help with below issue.
I have a Do Until ...Loop condition ,
Code:
Do Until X= "Ordered"  
          Call Login Function
          Browser().page().link().click
         Browser().Page().webbutton("Approve).click
         X = Browser().page().webelement("Status").GetROproperty ("Innertext")  
If  X = "Ordered" Then Exit DO
Loop
every time i login with a different username using datatable, click the required link and click Approve button, for every time i approve, the status changes to "Partially approved", "Approved", "Ordered". my loop continues till it finds the Ordered status
some times, we dont get Ordered status due to some acceptable errors or warnings. in such cases, is their any option to end the loop say after 15 times of exceution and still the ordered status is not found.


RE: How to end script in QTP if the Do Until loop goes to infinite. - vIns - 09-30-2011

Hi Uma,
Have a counter.

Say

Code:
Counter=1 ' above the do loop

Counter = Counter + 1
If Counter > 15 Then
    End Do
End If
somethign liek this


RE: How to end script in QTP if the Do Until loop goes to infinite. - uma87 - 09-30-2011

Thanks for reply. but I'm not getting where to fit that code in Do loop . if I put the code above do loop i get error at "End DO" as this is not defined . If I fit this in Do loop my logic is missing. can you suggest me pls.


RE: How to end script in QTP if the Do Until loop goes to infinite. - rajpes - 09-30-2011

Code:
For i=1 to 15
Call Login Function
Browser().page().link().click
Browser().Page().webbutton("Approve).click
X = Browser().page().webelement("Status").GetROproperty ("Innertext")
if X = "Ordered" then exit for
next