I recently had to test a .NET grid that did not have a way for me to easily see its row/cell data. After doing a little digging, I was able to find a method that returned to me the full text of a specified row. The only issue was that it was in an XML format. Luckily, though, I was able to get the cell data I needed by using the COM interface Microsoft.XMLDOM to create a QTP parser function.
Get text from specified node example:
Here is an abridged version of the XML string that the grid’s.NET method was returning to me:
currentRow = currentRow = "<schAppt><ApptDate></ApptDate><ApptDay>THU</ApptDay><ApptNumber>37015</ApptNumber><ApptSetAnchorFlag></ApptSetAnchorFlag><Copay></Copay><Department>TA PRIMARY CARE</Department><ProviderName>TAPRIM2</ProviderName></schAppt>"
' First create a instance of the Microsoft XMLDOM object.
set xmlDoc = CreateObject("Microsoft.XMLDOM")
'Next point to the XML string.
'If this was a xml file rather then a xml string you would use xmlDoc.Load("C:\myXML.xml") instead
' Find the specified element
strSearchNode = "ApptNumber"
'getElementsByTagName returns a NodeList of all a elements with the specified element name
Set NodeList = xMLDoc.getElementsByTagName(strSearchNode)
For Each Node In NodeList
strCurrentNodeValue = node.text
strNodeFoundFlag = "True"
If strNodeFoundFlag = "True" Then
appt = strCurrentNodeValue
appt = "No node found matching the name you specified"
'This will Return the value of 37015
To see this code in action check out my video post: "How to test a web service with QTP"