Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dynamic wait in QTP
#1
Solved: 10 Years, 8 Months, 3 Weeks ago
[/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
Reply
#2
Solved: 10 Years, 8 Months, 3 Weeks ago
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

Reply
#3
Solved: 10 Years, 8 Months, 3 Weeks ago
Thanks Saket.

I have coded the above logic using timer functions
Reply
#4
Solved: 10 Years, 8 Months, 3 Weeks ago
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 Wink
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.
Reply
#5
Solved: 10 Years, 8 Months, 3 Weeks ago
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.
Reply
#6
Solved: 10 Years, 8 Months, 3 Weeks ago
Hi,
I have tried with Basanth code which is while loop condition but i am not able to execute with that which is making some syntactical errors

so i tried with some of the logics given by basanth and finally publishing here
Please let me know if there is solution apart from these
and please correct me if i am going in wrong direction

Code:
function timer1()
For j=1 to 2 step 1
For i=1 to 10000 step 1
m=Browser("xxxxxxxx").WinStatusBar("msctls_statusbar32").GetROProperty("text")
If m="Done" Then
    wait 1
Exit for
End If
Next
Next
end function

I have tried using only one single loop instead of two loops and i was getting errors with that single loop so finally i have added one more loop to solve that issue

Thanks in advance
Venkat Batchu
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to identify dynamic webtable as unique in QTP? sudheendramurthy 4 18,071 02-23-2016, 06:16 PM
Last Post: vinod123
  What is the procedure to wait after select the webradio group.? Uma 2 3,759 09-29-2011, 02:07 AM
Last Post: Uma
  How to compare Dynamic PDF content via QTP. upadhyay40 0 3,251 12-10-2010, 03:16 PM
Last Post: upadhyay40

Forum Jump:


Users browsing this thread: 1 Guest(s)