Micro Focus QTP (UFT) Forums
Do Until Loop issue - 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 Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Do Until Loop issue (/Thread-Do-Until-Loop-issue)



Do Until Loop issue - mv8167 - 09-08-2011

Can anyone help me straighten out my Do Loop?

Code:
Do Until Browser("Wisdom").Page("WisdomLogin").Frame("parent").WebElement("Account Documents", "visable:=" &True).Exist(0)
    Wait(1)
Loop
Thx


RE: Do Until Loop issue - tarun - 09-08-2011

If you are using this loop to verify if the web element is visible or not, then you can also use the following

Code:
sLoop = True
Do Until sLoop
If cStr(Browser().Page().Frame().WebElement("Account Documents").GetROProperty("Visible")) = "True" Then
    sLoop = False
else
   wait(1)
End if
Loop



RE: Do Until Loop issue - mv8167 - 09-08-2011

Thx, I will give this a try. I just thought I could pull this off all in three lines. I guess not. ;-) thxx


RE: Do Until Loop issue - supputuri - 09-09-2011

Hi Guys,

Just think out of box, what will happen if the application is crashed once the do loop is initiated? The script will never come back.

So the best practice is when ever you are using do loop make sure you have initiate the time elapse.
Below is the snippet, if you feel it's worth keeping the time then you can goahead and use this.
Code:
Dim strInitialTime  : strInitialTime = Now()
Dim boolFlag : boolFlag = False
Do until boolFlag = False or DateDiff("n",strCurrentTime,Now())< 3
  'here you can specify your condition to check.
  'First of all Check whether that object exist or not
  If Browser().Page().Frame().WebElement("Account Documents").Exist(0) Then
     If Browser().Page().Frame().WebElement("Account Documents").GetROProperty("Visible") = True Then
       boolFlag = True
     Else
       wait 1
     End If
  Else
     msgbox "Specified object doesn't exist.
     ExitDo
  End If
Loop
If boolFlag = False Then
msgbox "Object does not meet the condition with in 3 minutes."
End If
Please let me know if you need any further info.


RE: Do Until Loop issue - mv8167 - 09-09-2011

Perfect, im clear ;-)

thx Supputuri