Facebook

Course Name Start Date Time Duration Registration Link
No Training Programs Scheduled ClickHere to Contact
Please mail To sudhakar@qtpsudhakar.com to Register for any training

Monday, May 3, 2010

Scripting Page Checkpoint

A standard checkpoint applied on a web page object is called as page check point. A Page check point checks for 3 basic properties.

  1. Load Time
  2. Number of Links
  3. Number of images
These 3 properties will not be displayed in object spy / object identification window. But GetROproperty method will return the values of these properties.

lTime=Browser("Google").Page("Google").GetROProperty("load time")
lCount=Browser("Google").Page("Google").GetROProperty("number of links")
iCount=Browser("Google").Page("Google").GetROProperty("number of images")
Msgbox "Page Load Time="&lTime
Msgbox "Number of Links in Page="&lCount
Msgbox "Number of Images in Page="&iCount


The above code display the values of Page load time, Number of Links in Page and Number of Images in Page.

Now we can write a function to check these properties for any page object. Use below function to check page properties.


Function CheckPageProperties(oPageObject,eLoadTime,eNumberOfLinks,eNumberOfImages)
Dim aLoadTime
Dim aNumberOfLinks
Dim aNumberOfImages
Dim cDecription
aLoadTime= oPageObject.GetROProperty("load time")
aNumberOfLinks= oPageObject.GetROProperty("number of links")
aNumberOfImages= oPageObject.GetROProperty("number of images")
 
If aLoadTime=eLoadTime and aNumberOfLinks=eNumberOfLinks and aNumberOfImages=eNumberOfImages Then
Reporter.ReportEvent micPass,"CheckPageProperties","Page Load Time="&aLoadTime&vbnewline&_
"Number Of Links="&aNumberOfLinks&vbnewline&"Number Of Images="&aNumberOfImages
Else
cDecription="<table border=1><tr><th>Property Name</th><th>Expected Value</th><th>Actual Value</th></tr>"&_
"<tr><td>Load Time</td><td>"&eLoadTime&"</td><td>"&aLoadTime&"</td></tr>"&_
"<tr><td>Number of Links</td><td>"&eNumberOfLinks&"</td><td>"&aNumberOfLinks&"</td></tr>"&_
"<tr><td>Number of images</td><td>"&eNumberOfImages&"</td><td>"&aNumberOfImages&"</td></tr>"&"</table>>"
Reporter.ReportEvent micFail,"CheckPageProperties",cDecription
End If
End Function
 
'Using the above function
RegisterUserFunc "Page","CheckPageProperties","CheckPageProperties"
Browser("Google").Page("Google").CheckPageProperties 3,39,5
UnregisterUserFunc "Page","CheckPageProperties"

2 comments :

  1. I just love it..just awesome ..I like cDecription..Very good presentation of result page..thanks lot..

    ReplyDelete
  2. why are you using opageobject,eloadtime not simple like page object..............

    ReplyDelete