Here is a very handy structure for dealing with objects contained in a web frame:
Set rc = frmObj.Object.getElementsByTagName(“IMG”)
numObjs = rc.length
If numObjs > 0 Then
For i=0 to numObjs-1
objClass = “” : objText = “” : objID = “”
On Error Resume Next
objClass = rc.Item(i).className
objText = rc.Item(i).innerText
On Error GoTo 0
‘ condition to check, stuff to do:
If objID = “_toolbar_rsimg” Then
‘frmObj’ is set to the definition of some frame in a web application, as in this example of descriptive programming:
Set frmObj = Browser(“name:=My Web App”).Page(“title:=My Web App”).Frame(“name:=My Frame One”)
‘getElementsByTagName’ is a method of the Frame object.
For the child objects, you can use any of their “Run-time Object Properties” and Methods, which are often more useful than the QTP “Test Object Properties”. And sometimes more stable (like .click).
The section which captures the object properties has error trapping turned off (‘On Error Resume Next’) in case the child object in question does not support a particular property. Since the capture variables (objClass, objText, objID) are set to null at the start of each iteration, they won’t retain any previous values if an error does occur, so they can still be used to evaluate whatever condition your are dealing with.