mardi 9 juin 2009

QTP tips: check the time to do an action

We all want to know how much time it takes for a page or an action to be done, because we need this to know if our website is fast or not.
In QTP you can check it on a very easy way by using the function "MercuryTimers".

For example:

Browser("browsername").Page("Pagename").Link("Link").Click
MercuryTimers("Timer1").Start 'Start measuring time using Timer1.
Browser("browsername").Page("Pagename").WebTable("Table").WaitProperty "visible", "true", 10000
MercuryTimers("Timer1").Stop 'Stop Timer1.
Reporter.ReportEvent micInfo, "Elapsed Time to display the booking restriction page", "Timer: " & MercuryTimers("Timer1").Stop() & "ms"
If MercuryTimers("Timer1").Stop() > 3000 Then
Reporter.ReportEvent micFail, "", "" 'Failed report if more than 3 seconds
End If

This is very simple, as you see and can be added everywhere in your scripts.
Please don't hesitate if you need details !

Aucun commentaire:

Enregistrer un commentaire