Monday 30 September 2013

Checking for Broken images on Web Page

'Function to check for broken images on Page

public function checkbrokenimages(opage)
pgtitle=opage.getroproperty("title")
set allimages=opage.object.images
icount=allimages.length-1
for i =0 to icount
set curimg=allimages.item(i)
shtml="HTML="&curimg.outerHTML
if curimg.filesize=-1 then
'the image didnt load
reporter.reportevent micfail,pgtitle& "Broken Image",shtml
else
reporter.reportevent micpass,pgtitle& "Valid Image",shtml
end if
next
end function

checkbrokenimages  browser("micclass:=browser","index:=0").page("micclass:=page")

Note:We have used the DOM in this example given above because QTP child objects function will not search in side the web table objects. Some of the images the web table might get ignored while using the childobjects method



No comments:

Post a Comment