'-------------------------------------------------------------------------------
Function GetManualTestsCollection
Const cProcName = \"GetManualTestsCollection\"
Dim cProcNameMsgPrefix
cProcNameMsgPrefix = cUnitNameMsgPrefix & cProcName & \"(): \"
Const cExt = \".tcMT\"
Dim Doc
Dim ManualTestCollection
Dim Nodes
Dim Node
Dim strManTCName
Dim i
Set ManualTestCollection = CreateObject(\"Scripting.Dictionary\")
Set GetManualTestsCollection = ManualTestCollection
If (\"\" = BuiltIn.GetCOMServerPath(\"Msxml2.DOMDocument.4.0\")) Then InstallMSXML
' Create COM object
Set Doc = Sys.OleObject(\"Msxml2.DOMDocument.4.0\")
Doc.async = False
' Load data from the current project file
Call Doc.load(Project.FileName)
' Report an error, if, for instance, the markup or file structure is invalid
If (Doc.parseError.errorCode <> 0) Then
s = \"Reason:\" & vbTab & Doc.parseError.reason & vbCrLf & _
\"Line:\" & vbTab & CStr(Doc.parseError.line) & vbCrLf & _
\"Pos:\" & vbTab & CStr(Doc.parseError.linePos) & vbCrLf & _
\"Source:\" & vbTab & Doc.parseError.srcText
' Post an error to the log and exit
Call Log.Error(cProcNameMsgPrefix & \"Error when parsing the project file.\", _
Project.FileName & vbCrLf & s)
Set Doc = Nothing
Exit Function
End If
' Use an XPath expression to obtain the list of Manual tests nodes
'/Nodes/Node[@name=\"root\"]/Node[@name=\"child list\"]/Node/Node[@name=\"item data\"]/Prp[@name=\"storage\"]
'/Nodes/Node//*/Prp[@name=\"storage\"]
'//Prp[@name=\"storage\"]
' Set Nodes = Doc.selectNodes(\"//Prp[@name=\"\"storage\"\"]\")
' Set Nodes = Doc.selectNodes(\"//Node[contains(@name,\"\".tcmt\"\")]\")
' Case insensitive search for the 'name' nodes that contain the cExt ('.tcMT') extension
' Based on:
' http://stackoverflow.com/questions/614797/xpath-find-a-node-that-has-a-given-attribute-whose-value-contains-a-string
' http://www.dotnetspider.com/resources/470-Doing-case-InSensitve-comparisons-using-XPa-X.aspx
'Set Nodes = Doc.selectNodes(\"//Node[contains(translate(@name, \"\"abcdefghijklmnopqrstuvwxyz\"\", \"\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\"),translate(\"\"\" & cExt & \"\"\", \"\"abcdefghijklmnopqrstuvwxyz\"\",\"\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\"))]\")
' Return 'name' nodes that ends on cExt value (case insensitive compare)
' Case insensitive search for the 'name' nodes that end on the cExt ('.tcMT') extension
' Based on:
' http://stackoverflow.com/questions/614797/xpath-find-a-node-that-has-a-given-attribute-whose-value-contains-a-string
' http://www.dotnetspider.com/resources/470-Doing-case-InSensitve-comparisons-using-XPa-X.aspx
' http://bytes.com/topic/xml/answers/726552-xpath-query-ends
Set Nodes = Doc.selectNodes(\"//Node[substring(translate(@name, \"\"abcdefghijklmnopqrstuvwxyz\"\", \"\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\"), string-length(@name) - string-length(\"\"\" & cExt & \"\"\") + 1, string-length(@name)) = translate(\"\"\" & cExt & \"\"\", \"\"abcdefghijklmnopqrstuvwxyz\"\",\"\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\")]\")
' Process the nodes
For Each Node In Nodes
For i = 0 To Node.attributes.length-1
' If (\"value\" = Node.attributes(i).name) Then
If (\"name\" = Node.attributes(i).name) Then
strManTCName = Node.attributes(i).text 'e.g. ManualTests\\ManualTest1\\ManualTest1.tcMT
' If (0 = aqString.Compare(aqFileSystem.GetFileExtension(cExt), _
' aqFileSystem.GetFileExtension(strManTCName), False)) Then ' case insensitive compare
' get file name (without path and ext.)
strManTCName = Utilities.ChangeFileExt(aqFileSystem.GetFileName(strManTCName), \"\")
If (\"\" <> strManTCName) Then ManualTestCollection.Add strManTCName, Eval(strManTCName)
' End If
End If
Next
Next
Set Doc = Nothing
End Function
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
Function GetManualTestsCollection
Const cProcName = \"GetManualTestsCollection\"
Dim cProcNameMsgPrefix
cProcNameMsgPrefix = cUnitNameMsgPrefix & cProcName & \"(): \"
Const cExt = \".tcMT\"
Dim Doc
Dim ManualTestCollection
Dim Nodes
Dim Node
Dim strManTCName
Dim i
Set ManualTestCollection = CreateObject(\"Scripting.Dictionary\")
Set GetManualTestsCollection = ManualTestCollection
If (\"\" = BuiltIn.GetCOMServerPath(\"Msxml2.DOMDocument.4.0\")) Then InstallMSXML
' Create COM object
Set Doc = Sys.OleObject(\"Msxml2.DOMDocument.4.0\")
Doc.async = False
' Load data from the current project file
Call Doc.load(Project.FileName)
' Report an error, if, for instance, the markup or file structure is invalid
If (Doc.parseError.errorCode <> 0) Then
s = \"Reason:\" & vbTab & Doc.parseError.reason & vbCrLf & _
\"Line:\" & vbTab & CStr(Doc.parseError.line) & vbCrLf & _
\"Pos:\" & vbTab & CStr(Doc.parseError.linePos) & vbCrLf & _
\"Source:\" & vbTab & Doc.parseError.srcText
' Post an error to the log and exit
Call Log.Error(cProcNameMsgPrefix & \"Error when parsing the project file.\", _
Project.FileName & vbCrLf & s)
Set Doc = Nothing
Exit Function
End If
' Use an XPath expression to obtain the list of Manual tests nodes
'/Nodes/Node[@name=\"root\"]/Node[@name=\"child list\"]/Node/Node[@name=\"item data\"]/Prp[@name=\"storage\"]
'/Nodes/Node//*/Prp[@name=\"storage\"]
'//Prp[@name=\"storage\"]
' Set Nodes = Doc.selectNodes(\"//Prp[@name=\"\"storage\"\"]\")
' Set Nodes = Doc.selectNodes(\"//Node[contains(@name,\"\".tcmt\"\")]\")
' Case insensitive search for the 'name' nodes that contain the cExt ('.tcMT') extension
' Based on:
' http://stackoverflow.com/questions/614797/xpath-find-a-node-that-has-a-given-attribute-whose-value-contains-a-string
' http://www.dotnetspider.com/resources/470-Doing-case-InSensitve-comparisons-using-XPa-X.aspx
'Set Nodes = Doc.selectNodes(\"//Node[contains(translate(@name, \"\"abcdefghijklmnopqrstuvwxyz\"\", \"\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\"),translate(\"\"\" & cExt & \"\"\", \"\"abcdefghijklmnopqrstuvwxyz\"\",\"\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\"))]\")
' Return 'name' nodes that ends on cExt value (case insensitive compare)
' Case insensitive search for the 'name' nodes that end on the cExt ('.tcMT') extension
' Based on:
' http://stackoverflow.com/questions/614797/xpath-find-a-node-that-has-a-given-attribute-whose-value-contains-a-string
' http://www.dotnetspider.com/resources/470-Doing-case-InSensitve-comparisons-using-XPa-X.aspx
' http://bytes.com/topic/xml/answers/726552-xpath-query-ends
Set Nodes = Doc.selectNodes(\"//Node[substring(translate(@name, \"\"abcdefghijklmnopqrstuvwxyz\"\", \"\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\"), string-length(@name) - string-length(\"\"\" & cExt & \"\"\") + 1, string-length(@name)) = translate(\"\"\" & cExt & \"\"\", \"\"abcdefghijklmnopqrstuvwxyz\"\",\"\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\")]\")
' Process the nodes
For Each Node In Nodes
For i = 0 To Node.attributes.length-1
' If (\"value\" = Node.attributes(i).name) Then
If (\"name\" = Node.attributes(i).name) Then
strManTCName = Node.attributes(i).text 'e.g. ManualTests\\ManualTest1\\ManualTest1.tcMT
' If (0 = aqString.Compare(aqFileSystem.GetFileExtension(cExt), _
' aqFileSystem.GetFileExtension(strManTCName), False)) Then ' case insensitive compare
' get file name (without path and ext.)
strManTCName = Utilities.ChangeFileExt(aqFileSystem.GetFileName(strManTCName), \"\")
If (\"\" <> strManTCName) Then ManualTestCollection.Add strManTCName, Eval(strManTCName)
' End If
End If
Next
Next
Set Doc = Nothing
End Function
'-------------------------------------------------------------------------------