Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Verifying the value exists and if not, wait up to 5min
#1
Solved: 10 Years, 8 Months, 3 Weeks ago
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.
Reply
#2
Solved: 10 Years, 8 Months, 3 Weeks ago
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
Reply
#3
Solved: 10 Years, 8 Months, 3 Weeks ago
I guess I didn't quite understand this. Can you give an example in the script?
Reply
#4
Solved: 10 Years, 8 Months, 3 Weeks ago
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Report Viewer showing hundreds of WebElement.Exists? themoon 1 2,210 03-09-2016, 02:43 PM
Last Post: vinod123
  Verifying a video in QTP msacks 2 2,180 11-14-2014, 08:26 PM
Last Post: msacks
  How to check whether data exists in excel.. venkatesh9032 1 2,906 03-06-2014, 04:37 PM
Last Post: supputuri
  Object does not exists shwetasharma 4 8,746 03-01-2013, 01:05 PM
Last Post: shwetasharma
  help with wait property function kp_usa 3 3,972 12-20-2012, 10:49 PM
Last Post: kp_usa

Forum Jump:


Users browsing this thread: 1 Guest(s)