QA Focus

Sep 16 2008   3:20AM GMT

function junction: Objects in a Web Frame

Sentinel627 Greg Annen Profile: Sentinel627

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
objID= rc.Item(i).id
On Error GoTo 0
‘ condition to check, stuff to do:
If objID = “_toolbar_rsimg” Then
rc.Item(i).FireEvent “onmouseover”
Exit For
End If
End If

‘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.

Try it!

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: