Reputation: 127
I have created a piece of code in vbscript through which I am able to create test scripts in ALM via OTA. Now I am trying to do the same thing through Java using JACOB as the Java 2 Com bridge and I have been able to create an empty test script using this, but I am not sure how to set the various field values.
VBScript Code (That works perfectly):
Set tdc = CreateObject("TDAPIOLE80.TDConnection")
If (tdc Is Nothing) Then
MSGBOX "Connection is not created"
Else
MSGBOX "Connection is created"
End If
tdc.InitConnectionEx connectionString
tdc.Login userName, password
tdc.Connect domain, project
Set TreeMgr = tdc.TreeManager
Set testFolder = TreeMgr.NodeByPath(uploadDirectoryPath)
Set testFactory = testFolder.TestFactory
Set testItem = testFactory.AddItem (NULL)
testItem.Field("TS_DESCRIPTION")="Test script description"
...
Java code (Only that much that works)
ActiveXComponent almConnection=new ActiveXComponent("TDAPIOLE80.TDConnection");
Dispatch.call(almConnection, "InitConnectionEx", "conn string");
Dispatch.call(almConnection, "login", "uname","pword");
Dispatch.call(almConnection, "connect","project","domain");
Dispatch treeMgr=Dispatch.get(almConnection, "TreeManager").toDispatch();
Dispatch testFolder=Dispatch.call(treeMgr,"NodeByPath", "project path").toDispatch();
Dispatch testFactory=Dispatch.get(testFolder, "TestFactory").toDispatch();
Dispatch testItem=Dispatch.call(testFactory,"AddItem","TO_BE_DELETED_SCRIPT9").toDispatch();
Now the issue is the last line in the VBScript code,
testItem.Field("TS_DESCRIPTION")="Test script description"
How do I code this in Java using JACOB? Please help. I have done a lot of google searching, but haven't found anything substantial.
Upvotes: 0
Views: 2548
Reputation: 21
This works for me:
Dispatch testItem=Dispatch.call(testFactory,"AddItem","TestName").toDispatch();
Dispatch.put(testItem, "Name", "newTestName");
Dispatch.call(testItem,"Post");
How to change field value in HPQC using JACOB:
http://sourceforge.net/projects/jacob-project/forums/forum/375946/topic/4830213
Upvotes: 2