Summary
Question
Answer
Object Repository that has been exported to xml format is a well formed xml document, so it can be iterated using available xml API as Microsoft.XLMDOM. Here is example code that will recursively traverse an xml object repository document to list all test objects creating the corresponding replay statement.
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("C:\repository.xml")Dim rootObjects, objParentNodes,objParentNode, objChildNode, objChildNodes, strNode, tabs
Set rootObjects = objXMLDoc.documentElement.getElementsByTagName("qtpRep:Objects")
For Each objParentNode In rootObjects
Set objParentNodes = objParentNode.ChildNodes
For Each objParent in objParentNodes
tabs = 1
Print "-------------------------[ Parent Object ]-------------------------------------"
Print objParent.getAttribute("Class") & "(""" & objParent.getAttribute("Name") & """)"
Call describeOR(FindChildObjectsNode(objParent), tabs)
Next
NextSet objParentNodes = Nothing
Set objXMLDoc = NothingFunction describeOR(xmlNode, tabs)
If xmlNode.hasChildNodes Then
tabs = tabs + 1
For Iterator = 1 To tabs
strTabs = strTabs & vbTab
Next
For Each strNode in xmlNode.childNodes
Print strTabs & strNode.getAttribute("Class") & "(""" & strNode.getAttribute("Name") & """)"
Call describeOR(FindChildObjectsNode(strNode), tabs)
Next
End If
End FunctionFunction FindChildObjectsNode(xmlNode)
If xmlNode.hasChildNodes Then
Set chlObjs = xmlNode.getElementsByTagName("qtpRep:ChildObjects")
Set FindChildObjectsNode = chlObjs(0)
Set chlObjs = Nothing
End If
End Function
The code above will produce an output similar to this:
-------------------------[ Parent Object ]-------------------------------------
Window("Temp")
WinObject("Items View")
WinList("Items View")
-------------------------[ Parent Object ]-------------------------------------
Dialog("Windows Task Manager")
WinCheckBox("Show processes from all")
WinButton("End Process")
-------------------------[ Parent Object ]-------------------------------------
Browser("Tryit Editor v2.3")
Page("Tryit Editor v2.3")
Frame("Frame")
WebElement("Search w3schools.com:")
-------------------------[ Parent Object ]-------------------------------------
Browser("Google")
Page("Google")
WebElement("SearchButton")
WebEdit("SearchText")
DISCLAIMER