Posts: 5
Threads: 2
Joined: Jul 2009
Reputation:
0
10-07-2009, 05:08 PM
[/color]Hi,
My application opens after I give the login details .
In the above situation QTP should wait till the aplication page appears. If aplication is not opened with in 3 min then I have to exit the run .
We have to do the scripting in QTP with out using wait statement[color=#9400D3]. Could any one provide me the solution
Thanks in advance
Posts: 1,199
Threads: 5
Joined: Nov 2008
Reputation:
0
10-07-2009, 05:13 PM
I can give you a logic on how to do this -
after login get the current time
do
check if your application exist
take the current time
get the time difference
make a flag status true
while time diff is 3 min
if flagstatus = false then exittest
Posts: 5
Threads: 2
Joined: Jul 2009
Reputation:
0
10-07-2009, 06:47 PM
Thanks Saket.
I have coded the above logic using timer functions
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
10-07-2009, 07:24 PM
Good. That is one of the way to use it. Which timer have you used ? Mercury.timers or timer ?
Always remember a While loop with the browser busy property will help you to get for the required time. skeletally like this,
Code:
i=0
a = Browser().getroproperty("busy")
While a=True
wait 1
i=i+1
loop Until a=False or i>30
I am pretty sure you will reply back saying "I dont want to use Wait". However your timer is only hoodwinking the wait. Timer is nothing but a delayed usage of wait
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Posts: 128
Threads: 9
Joined: Oct 2009
Reputation:
0
10-07-2009, 08:18 PM
I have to chime in here. I have not investigated timers in QTP yet, but I will. The difference between a While loop and a Wait statement is huge in my opinion.
While both options will get the required results, the difference is in the effect on the test system. A While Loop, Bansanth27's code withstanding because he uses a wait statment, will cause 100% CPU utilization during the loop. This may or may not affect your testing but it certainly can if you are waiting on an application that is utilizing resources heavily and can effect your timing of the application or test.
A Wait statment on the other hand is equivalent to the a .NET/VB Thread.sleep(). Your test application will actually go to sleep for the timeframe requested and have zero CPU utilization. I think this will give you better results in the long run if you are actually trying to measure an application performance.
Of course you need to remember there is no way to continue or break out of a wait statment. It will stay in effect for exactly how long you tell it to wait for. Bansanth27's code using a wait in a while gives a real world example of how to utilize the ability of the wait statement releasing resources for other applications as well as give it a conditional out.