有没有办法使用OTA来操作ALM中的测试计划?
例如,我在ALM中有350个测试计划,我想更改每个测试计划的参数设置。手动完成是很愚蠢的。
更新1:
在对OTA进行了数小时的研究之后,我现在就得到了:
通过使用以下代码,我可以参加测试计划并获取其名称,但仍然不知道如何获得其中的BPComponents的完整列表......
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似乎提供了一种编辑参数值的方法。但问题是Test
对象不支持Test.Load
方法。
更新2:
经过更多的研究,我认为我们不能通过UFT / QTP来做到这一点。原因是:根据OTA官方指南(链接here),我们需要将Test
投射到BusinessProcess
"。似乎这不能在VBScript中完成,因为VBS没有像Dim As
或CType
这样的东西。
下一步:也许我可以尝试在测试计划级别而不是组件级别上执行此操作?
答案 0 :(得分:0)
由我自己解决。
以下是详细信息:
首先,通过使用OTA,我们无法触及组件级别;但我们可以操纵测试计划/实验室水平。这意味着如果我们想要使用OTA更改参数值,我们需要在测试计划级别创建一个全局参数并进行更改。
以下是一些示例代码:
'=====================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==============