1

Is there any way to use OTA to manipulate test plans in ALM?

For example, I have 350 test plans in ALM and I want to change parameter settings for each of them. It is silly to do it manually.

Update 1:

After doing research about OTA for many hours, here are what I got now:

By using codes below, I can go to a test plan and get its name, but still don't know how to get a full list of BPComponents in it...

set tdc = createobject("TDApiOle80.TDConnection")
tdc.InitConnectionEx "http://URL:8080/qcbin"
tdc.Login "Username","Password"
tdc.Connect "Domain","Project"

If tdc.Connected = true Then
    print "Connect successful!!!"
End If

Set TreeMgr = tdc.TreeManager
    Set SubjRoot = TreeMgr.NodeByPath("Subject\")
    Set TestFact = tdc.TestFactory
    Set SubjectNodeList = SubjRoot.FindChildren("", False, "")

 For Each oSubjectNode In SubjectNodeList
        'Print out the subject path
        'Print oSubjectNode.Path

        'Does this have any tests?
        Set TestFilter = TestFact.Filter
        TestFilter.Filter("TS_SUBJECT") = Chr(34) & oSubjectNode.Path & Chr(34)
        Set TestList = TestFact.NewList(TestFilter.Text)
        For Each oTest In TestList
            print oTest.Name
'=============get stuck here========================
                Set Components=oTest.BPComponent
                Set Component=Components.Item(1)
'=============trying to get components list==========
            Next

Next  

This post seems provide a way to edit parameter values. But the issue is that the Test object doesn't support Test.Load method.

Update 2:

After more researching, I don't think we can do it through UFT/QTP. The reason is that: according to OTA official guide (link here), we need to "cast the Test to BusinessProcess". Seems this can't be done in VBScript because VBS doesn't have something like Dim As or CType.

Next step: maybe I can try to do it on test plan level but not component level?

nwpulele
  • 211
  • 3
  • 12

1 Answers1

0

Solved by myself.

Here are details:

First, by using OTA, we can't touch Component level; but we can manipulate test plan/lab level. Which means if we want to change parameter values using OTA, we need to create a global parameter at test plan level and change it.

Below are some sample codes:

'=====================Initial ALM Connection=================='
set tdc = createobject("TDApiOle80.TDConnection")
tdc.InitConnectionEx "ALM URL"
tdc.Login "UserName","Password"
tdc.Connect "Domain","Project"

If tdc.Connected = true Then
    print "Connect successful!!!"
else
    'do something'
End If
'=====================Initial ALM Connection=================='



'====================Get all test plans under a folder========================
    Set treeMng = tdc.TreeManager
    Set sourceFolder = treeMng.NodeByPath("Subject\Path")
    Set testF = sourceFolder.TestFactory
    ' Find the test ID.
     Set aFilter = testF.Filter
     Set TestList = testF.NewList("")
     For each test in TestList
        print test.Name
        '=========Can search a specific test plan here'
        If test.Name = "TestCaseName" Then
            set TestObj = test
        End If
     Next
'====================Get all test plans under a folder========================


'====================Modify test plan name===================='
'After get a specific TestObj
TestObj.Name = "New Name"
TestObj.Post
'====================Modify test plan name===================='


'====================Change parameter value=====================
Set para = TestObj.TestParameterFactory
Set paraList = Para.NewList("")
For each a in paraList
    If a.Name = "Para1" Then
        a.Name = "Modified1"
        a.DefaultValue = "ValueModified1"
        a.Post
        a.UnLockObject
    End If

    If a.Name = "para2" Then
        a.Name = "Modified2"
        a.DefaultValue = "ValueModified2"
        a.Post
        a.UnLockObject
    End If
Next
'====================Change parameter value=====================



'====================Search a specific test plan, copy and paste==============
Set treeMng = tdc.TreeManager
Set sourceFolder = treeMng.NodeByPath("Subject\Path")
Set testF = sourceFolder.TestFactory
' Find the test ID.
Set aFilter = testF.Filter
Set TestList = testF.NewList("")
TestName = """Test_Case_Name"""
aFilter.Filter("TS_NAME") = TestName
Set TestsList = aFilter.NewList()
Set Test = TestsList.Item(1)
print Test.id
Set iscp = testF
clipboard = iscp.CopyToClipBoard(Test.ID, 0, "")
Set destFolder = treeMng.NodeByPath("Subject\Path")
Set testF = destFolder.TestFactory
Set iscp = testF
iscp.PasteFromClipBoard clipboard,destFolder.NodeID,0,1
destFolder.Refresh
'====================Search a specific test plan, copy and paste==============
nwpulele
  • 211
  • 3
  • 12