QTP: Combining XMLDOM with regular QTP functionality

I've been talking a lot lately about how to use the XMLDOM to interact with elements in complicated structres to make finding them dynamically easier. This process is something I literally do everyday, and is the most reliable method I've found.

However, sometimes, I have found it most useful to use a combination of the two to get some work done.

For example, I had an occassion where there was code executed when I selected a value in a WebSelect using it's Select. However, simply setting the value in the XMLDOM wouldn't fire the code! So, here I was, with my object right in front of me, but couldn't interact with the part I needed. You see, I had to find the WebSelect by checking the field 2 columns to the right in the table. So, the properties of import (name, etc) of the WebSelect with which I had to select would change. So, here's what I did (this example contains only the loop, but none of the code that produced it...look at some of my earlier posts if you are interested in this)

For Each objRow in objRows
 lngCellCount = 0
 Set objCells = objRow.GetElementsByTagName("TD")
 For Each objCell in objCells
  lngCellCount = lngCellCount + 1
  Select Case lngCellCount
   Case 2
    Set objComboBoxes = objCell.GetElementsByTagName("SELECT")
    For Each objComboBox in objComboBoxes
     Set objPriority = objComboBox     
    Next 'oComboBox
   Case 5
    msgbox objCell.innertext
    If Instr(objCell.innertext, "WideOpen4") > 0 Then
     Browser("X").Page("X").Frame("X").WebList("name:=" & objPriority.name).Select "1"
    End If
  End Select
  'oTS.WriteLine Typename(objCell)
  Set objCell = Nothing
 Next 'objCell
 Set objCells = Nothing
Next 'objRow

Note that once I had made sure I was in the correct row (by verifying the value in the 5th cell of the row), I switched over to standard QTP descriptive programming to interact with the item. This is very dynamic, and ensures the code behind the select event is fired. Handy.

posted @ Thursday, October 19, 2006 2:39 PM

Print

Comments on this entry:

# re: QTP: Combining XMLDOM with regular QTP functionality

Left by Suchit at 2/20/2008 5:31 PM
Gravatar
I see a lot of good stuff here. Esp. currently I am kinda getting stuck playing along XML with QTP . If you can please comment the code, it would be a lot easy to understand for someone who hasn't been following (or is new to) your blogs since long.
Comments have been closed on this topic.
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910