Apocalyptica video

”Nothing Else Matters” can be found here. Very, very cool...if you like Classical and Heavy Metal. This string quartet rocks!

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.

«October»
SunMonTueWedThuFriSat
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234