Micro Focus QTP (UFT) Forums
Alternative for wait statement. - 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: Alternative for wait statement. (/Thread-Alternative-for-wait-statement)



Alternative for wait statement. - adpbinu - 01-30-2010

[/align]QTP 9.5 Build 194 - Testing web application (DNN)

The action is Search for a user -> Once the record is retrieved, click on the delete button next the retrieved record and it generated the following code, without the "wait" statement in between.

[color]Browser("QA SOL Portal > Home").Page("User Accounts").Image("dnn$ctr2508$Users$btnSearch").Click 11,6
wait(20)
Browser("QA SOL Portal > Home").Page("User Accounts_4").Image("dnn$ctr2508$Users$grdUsers$ctl").Click 6,6[/color]

It did not work without the wait statement as it went to the next line right after the search action without waiting for the record to be retrieved. Since the record was not there, it could not find the delete button which caused the script to fail.

Is there any way, other than using wait command, to make the script to wait for the record to be retrieved before executing the next statement?

Thanks,
Binu.


RE: Alternative for wait statement. - rdemers25 - 01-30-2010

I don't know if this works for browsers, but this is what I do on the clients. I would something like.

Code:
For i = 1 to 20
if Browser("QA SOL Portal > Home").Page("User Accounts_4").Exist(0)=True Then
Exit For
else
Wait 1
End If

So once the page is loaded it will stop the wait.


RE: Alternative for wait statement. - sreekanth chilam - 01-30-2010

Hi ,

Use "WaitProperty" method.

Refer the below example:
The following example uses the 'WaitProperty' method to wait for the required WebButton's 'readyState' property to be complete or for 10 seconds (10000 milliseconds) to pass, whichever comes first.
If the WebButton achieves this value for '4' seconds itself, then QTP clicks the button & ignores the remaining '6' seconds.

Example:
Code:
If Browser("....").Page("....").WebButton("....").WaitProperty("readyState", "Complete", 10000) Then
    Browser("....").Page("....").WebButton("....").Click
End If



RE: Alternative for wait statement. - vijayendra.shukla - 02-02-2010

Hi,

You can use the while wend as well.

Code:
While Browser("....").Object.Busy = True
'Do Nothing
Wend

Or you can insert Wait statement within it. But put wait only for 2 seconds or so, so that the moment object is loaded it does not go for the Wait statement inside.

Code:
While Browser("....").Object.Busy = True
Wait (2)
Wend


HTH
Vijayendra


RE: Alternative for wait statement. - adpbinu - 02-05-2010

I was able to get this done using the while loop. Thank you, everyone, for the help.

Thanks,
Binu.