Micro Focus QTP (UFT) Forums
Verifying the value exists and if not, wait up to 5min - 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: Verifying the value exists and if not, wait up to 5min (/Thread-Verifying-the-value-exists-and-if-not-wait-up-to-5min)



Verifying the value exists and if not, wait up to 5min - HeZma - 02-19-2012

I have an application which has a list and it contains a specific value. However, this value might not show up right away, so QTP has to wait up to 5min if the value comes. List might contain other values, but QTP will ignore them and try to wait this one specific value to show up. It also has to check every 60 seconds if the value has shown up or not. If the value doesn't show after 5min, the test will fail. So far I don't have a success with this case and I believe this forum has more smarter people than I am.

This example is for Flight demo in QTP:

---------------
'Add username
Code:
Dialog("Login").WinEdit("Agent Name:").Set "test"
wait 2
'Add password
Code:
Dialog("Login").WinEdit("Password:").SetSecure "4f40ca43f5ea941e580ed802a32e35c74d81d6ce"
wait 2

'If the value is not correct, then check the value 5 times
Code:
For i = 1 to 5
'Verify the value in username field is "test2", if the value is correct, then click "OK" button
Code:
if Dialog("Login").WinEdit("Agent Name:").Check CheckPoint("test2") = True Then
Dialog("Login").WinButton("OK").Click
Exit For
'Exit loop

'if value is not correct, wait 1min and try again
Code:
else        
wait 60
Next
End if
---------------

And before anyone says: I know that this case doesn't make any sense in Flight Demo (it will/should fail after 5min because the value is not correct), but I just want to understand how this is made. At the moment I can't even run the script.


RE: Verifying the value exists and if not, wait up to 5min - anil2u - 02-20-2012

Hi,

You cant use a checkpoint in If condition. Retrieve the 'all items' property value of the list and check if your desired value is there using 'instr' function.

If you dont want use that then you need to retrieve each value in the list using a for loop and check if that is your desired value or not.

Hope this helps,
Anil


RE: Verifying the value exists and if not, wait up to 5min - HeZma - 02-23-2012

I guess I didn't quite understand this. Can you give an example in the script?


RE: Verifying the value exists and if not, wait up to 5min - rajpes - 02-25-2012

Writing a for loop with i=1 to 5 doesnt mean it waits for 5 minutess.
Go to checkpoint properties configure checkpoint timeout to 300 seconds.