Retrieving Parameter Actual values from Test Instance properties from QTP or VAPI-XP

Hi,

I am unable to to get Parameter Actual values from Test Instance Properties/Configuration tab to QTP or VAPI-XP, i am using the following code, if you observe for 'TestParameter Object' there is no Public property like 'ActualValue', i think its a DEFECT in QC OTA methods. Please see attachement for further info.

 

can anyone please suggest a solution.

 

'***************Code**********************
Set tdc = createobject("TDApiOle80.TDConnection.1")

Set TDConnection = QCUtil.QCConnection

Set TSetFact = TDConnection.TestSetFactory
Set tsTreeMgr = TDConnection.TestSetTreeManager

Set tsFolder = tsTreeMgr.NodeByPath("Root\Test 1")

Set tsList = tsFolder.FindTestSets("Test")
If tsList.Count > 1 Then
Msgbox "FindTestSets found more than one test set"
ElseIf tsList.Count < 1 Then
Msgbox "FindTestSets: test set not found"
End If

Set theTestSet = tsList.Item(1)

Set testSubjectFolder = GetSubjectNodeByPath("Subject\Test2")
Set tList = testSubjectFolder.FindTests("Test val")
If tList.Count > 1 Then
Msgbox "FindTests found more than one test"
ElseIf tList.Count < 1 Then
Msgbox "FindTests: test not found"
End If

Set theTest = tList.Item(1)

msgbox theTest.ID
msgbox theTest.Name

Set TestParamsFct = theTest.TestParameterFactory
Set TestParamFctList = TestParamsFct.NewList("")

 

For i = 1 to TestParamFctList.Count

    msgbox TestParamFctList.Item(i).Name

Next

 

' here i am able to get Parameter Names from the List, but Acutal Values are not returning



'Set TPValueFact = theTest.ParameterValueFactory
'Set TPValueList = TPValueFact.NewList("")

msgbox theTest.Name

'***********************************************************************
Public Function GetSubjectNodeByPath(ByVal fullPath)
delimChar = "\"

' This function returns the Test SubjectNode object
' corresponding to the lowest level of a path.
' The path format is:
' "OTA_DEMO_SUBJECT\OTA_SUBJECT_level1\OTA_SUB_1.1\OTA_SUB_1.1.1\OTA_SUB_1.1.1.1"
' If a backslash is not used as the folder delimiter, any other
' character can be passed in the delimChar arguement.
Dim TreeMgr 'As TreeManager
Dim SubjRoot 'As SubjectNode
Dim SubNode
Dim Trees
Dim CurrentSubName

Set tdc = TDConnection
'On Error GoTo GetSubjectNodeByPathErr

' Get the list of subject root nodes from the tree manager.
' There is only one item in this list.
'tdc is the global TDConnection object.
CurrentSubName = "Set TreeMgr = tdc.TreeManager"
Set TreeMgr = tdc.TreeManager
'----------------------------------------------------------
' Use TreeManager.RootList to get the Subject root.
Set Trees = TreeMgr.RootList(TDOLE_SUBJECT)
' Get the name of the subject tree root in your project.
CurrentSubName = Trees.Item(2)
'----------------------------------------------------------
' Use TreeManager.TreeRoot to get the root node object
' from the tree manager by name.
Set SubjRoot = TreeMgr.TreeRoot(CurrentSubName)
' If fullPath is empty string, return the root.
If Len(fullPath) = 0 Then
Set GetSubjectNodeByPath = SubjRoot
Exit Function
End If
' Trim the fullPath and strip leading and trailing delimiters.
fullPath = Trim(fullPath)
Dim pos, ln

pos = InStr(1, fullPath, delimChar)
If pos = 1 Then
fullPath = Mid(fullPath, 2)
End If
pos = InStr(fullPath, CurrentSubName)
If pos = 1 Then
fullPath = Mid(fullPath, Len(CurrentSubName) 2)
End If

ln = Len(fullPath)
pos = InStr(ln - 1, fullPath, delimChar)
If pos > 0 Then
fullPath = Mid(fullPath, 1, ln - 1)
End If

' Set up to walk the tree.
Set SubNode = SubjRoot
' Split the path into individual node names.
Dim subjectArray
subjectArray = Split(fullPath, delimChar)

' If path is not directly under root then
' walk down path.
If LBound(subjectArray) < UBound(subjectArray) Then
Dim idx
' Debug.Print LBound(subjectArray), UBound(subjectArray)
For idx = LBound(subjectArray) To UBound(subjectArray) - 1
CurrentSubName = subjectArray(idx)
msgbox SubjRoot.Name & delimChar & CurrentSubName
'---------------------------------------------------------------
' Use SubjectNode.FindChildNode to get a specifed node.
Set SubNode = SubjRoot.FindChildNode(CurrentSubName)
Set SubjRoot = SubNode 'for next loop
Next
End If 'lbound < ubound

' Get the last node.
CurrentSubName = subjectArray(UBound(subjectArray))
msgbox SubjRoot.Name & delimChar & CurrentSubName
'Debug.Print SubjRoot.Name & delimChar & CurrentSubName
Set SubNode = SubjRoot.FindChildNode(CurrentSubName)
msgbox subNode.Name
' Return the last node.
Set GetSubjectNodeByPath = SubNode
Exit Function
GetSubjectNodeByPathErr:
On Error Resume Next
Dim errmsg
errmsg = "Error processing " & vbCrLf & fullPath _
& vbCrLf & "near " & CurrentSubName
Set GetSubjectNodeByPath = Nothing
ErrHandler err, "GetSubjectNodeByPath", errmsg, NON_FATAL_ERROR
End Function

Parents
  • You have to use the ParameterValueFactory.  You get the Parameter by casting the Test Instance to the ParameterValue.  Then the parameter has an ActualValue property. 

     

    Use this code as example.  It is just setting the actual value of each parameter of an instance to its own name and an index number.

     

        Dim aParam As ISupportParameterValues
        Dim aTS As TSTest
        Dim aList As List
        Dim paramValueFct As IBaseFactory

        Set aList = tstfact.NewList("")
        Set aTS = aList(1)

     

        Set aParam = aTS
       
        Set paramValueFct = aParam.ParameterValueFactory
        Set lst = paramValueFct.NewList("")
        Index = 1
        For Each param In lst
            With param
                .ActualValue = .Name & Index
                .Post
                Index = Index 1
            End With
        Next param

  • I have seen this example before, but I am having problems.  Maybe someone can enlighten me.

     

    To my knowledge, you cannot declare variables in this fashion nor type cast in vbscript.  VBScript is what I am using to create my VAPI-XP script.  This example appears to be visual basic.  When I try to use the example, I get syntax errors.  What am I doing wrong?

  • VBScript doesn't work with the data type so just comment out the "As  ISupportParameterValues" so you end up with  

    Dim aParam ' As ISupportParameterValues.  
      
      

Reply Children
No Data