Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
To calculate the page load time using a user defined function
#1
Solved: 10 Years, 9 Months ago
I have written the following function to calculate the load time for a page.
Objective: Google home page opens
Click on Google Maps link
Get StartTime
Once Google Maps page arrives, get StopTime
Difference between StopTime and StartTime is the time the page takes to load.

Problem:
Even after the last step, the arrow is again at Step 3
(Browser("Bro_Google").Page("Pag_Google").Link("name:="&LnkName).Click)
It doesnt stop at the last line,i.e at msgbox and doesnt provide me the result.
Also, the result for msgbox StartTime is empty, no value
and for StopTime its 0..

Code/Function is:

Code:
Public Function CheckLoadTime(ByVal LnkName,ByVal BroName,ByVal PagTitle)
Browser("Bro_Google").Page("Pag_Google").Sync
Browser("Bro_Google").Page("Pag_Google").Link("name:="&LnkName).Click
StartTime=MercuryTimers.Timer("Timer1").Start
msgbox StartTime
Browser("name:=" & BroName).Page("title:=" & PagTitle).Sync
StopTime=MercuryTimers.Timer("Timer2").Stop
msgbox StopTime
CheckLoadTime=StopTime-StartTime
End Function
Call CheckLoadTime("Maps","Google Maps","Google Maps")
msgbox CheckLoadTime(LnkName,BroName,PagTitle)

Saket,I am Sorry, I meant to post another issue I am facing in the same context, but I posted the old query.Sorry.


Please help.


-Joshi
#2
Solved: 10 Years, 9 Months ago
Hi Joshi,
It is causing because you have sarted a timer('Timer1' ) and stopping another timer ('Timer2').
if you have started timer1 then you should stop the same timer only.

you can use ElapsedTime method to get the time required to do the mentioned action by QTP.

the aother issue has been discussed in another thread by you - solution is use only a single statement to call you function.
if you will call it twice then obviously it will stuck at the position you mentioned

try the code below

Code:
Public Function CheckLoadTime(ByVal LnkName,ByVal BroName,ByVal PagTitle)
Browser("Google").Page("Google").Sync
Browser("Google").Page("Google").Link("name:="&LnkName).Click
wait(2)
StartTime=MercuryTimers.Timer("Timer1").Start
Browser("name:=" & BroName).Page("title:=" & PagTitle).Sync
StopTime=MercuryTimers.Timer("Timer1").Stop
CheckLoadTime=MercuryTimers("Timer1").ElapsedTime
End Function

msgbox CheckLoadTime("Maps","Google Maps","Google Maps")

#3
Solved: 10 Years, 9 Months ago
Thanks everyone!
I get it now.
Smile
I have a question. I want to see the load time,no. of links etc using the checkpoint now, for Google homepage.
I inserted the standard checkpoint(while recording), I have load time=2, no. of images=3, no. of links=30.
Now, when I run the recorded script(checkpoint) on Google homepage, it fails.
According to the results,it failed for "install Google chrome" link and "make Google my homepage" link.
Why does this happen?
Thanks,
Joshi
#4
Solved: 10 Years, 9 Months ago
Hi Joshi,

Please open a new thread for your new question.
always put one query per thread.

!!Thread is closed now!!



Possibly Related Threads…
Thread Author Replies Views Last Post
  Error as Global Not defined while trying to retrieve value from Datatable siddharth1609 0 847 09-11-2019, 02:52 PM
Last Post: siddharth1609
  Load testing in QTP newqtp 4 6,983 01-24-2019, 11:32 AM
Last Post: sonali31
  How to get input from the user in QTP? shanthiK 10 18,051 08-07-2017, 11:34 PM
Last Post: zunebuggy
  Calling a function in a Test Script from a function library anupam4j 3 5,902 06-26-2015, 12:31 AM
Last Post: babu123
  Reporter unable to load results when objects are involved? Elimelech.Eli 2 3,457 06-01-2014, 01:37 PM
Last Post: Elimelech.Eli

Forum Jump:


Users browsing this thread: 1 Guest(s)