Friday 9 December 2016

Measuring time taking to load object with QTP / UFT (Performance Testing with UFT)

Unlike LoadRunner or any performance testing tools, with QTP/UFT we can't reach to hard core features like running script with multiple Virtual Users as thread or a process. But we can get time taking to load for objects we are looking for.

This is pretty simple by implementing a simple loop and verify for the object is loaded. Below is the code snippet for the same.

Browser("BrowserName").Page("PageName").WebEdit("user").Set "XXXX"
Browser("BrowserName").Page("PageName").WebEdit("password").SetSecure "XXXX"
Browser("BrowserName").Page("PageName").Image("Login").Click
dblStartTime =  timer

set  objLink = Browser("BrowserName2").Page("PageName2").Link("Link1")

blnStatus = WaitForObject(obj)

dblEndTime = timer
'Print blnStatus
'Print dblStartTime
'Print dblEndTime
Print (dblEndTime-dblStartTime)

Function WaitForObject(obj)
    WaitForObject = false
    For i = 0 to 10
        If obj.Exist Then
            WaitForObject = true
            Exit For
        End If
    next

End function