Regular Contributor.
Regular Contributor.
260 views

TestSet Execution flow in VBA using ALM OTA

Jump to solution

I want to create the TestSet execution flow using VBA script . when i try Add New ConditionFactory item using Additem - it throws error stating as wrong number of arguments or Invalid property assignment. Does anyone used OTA to create the execution flow in ALM. If yes can please provide the sample code.

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TestSet Execution flow in VBA using ALM OTA

Jump to solution

It seems ConditionFactory doesn't accept Null to create a virtual entity.

You may use below way to create and post your conditions:

Set condFactory = theTestSet.ConditionFactory
' Create an array with this order: Type, Source, Target, Value, Desc (This was edited to correct the order)
CondArr = Array(1, 6, 7, 2, "Sample")

condFactory.AddItem(CondArr)
condFactory.Save

By this way, you should be able to create Execution Condition for Test Set.

View solution in original post

11 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TestSet Execution flow in VBA using ALM OTA

Jump to solution

Hi,

Please post your core code example if it's a coding issue. Then some professionals can help to figure out if there is a coding problem or usage issue.

Basically, the ConditionFactory should be fetched from TestSet via its ConditionFactory property.

TestSet.ConditionFactory property

And then use AddItem function 

Best Regards,
Mike

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Re: TestSet Execution flow in VBA using ALM OTA

Jump to solution

 

I used the below code to add the New item but it is not added

Set oCurrentTestSet = oTestSet
Set otestFac = oCurrentTestSet.TSTestFactory
Set otestlist = otestFac.NewList("")
Msgbox otestlist.Count
For each tstest in otestlist

Msgbox "ID: " & tstest.ID &"Name: "& tstest.Name & "Status :" & tstest.Status
If tstest.Name = sSource Then sSrcID = Clng(tstest.ID)
If tstest.Name = sTarget Then sTrgID = Clng(tstest.ID)


Next
sCondType = Clng(1)
sValue = "TDCOND_PASSED"

 

Set testSetConditionFactory = oCurrentTestSet.ConditionFactory
CreateFlow testSetConditionFactory,sSrcID,sTrgID,sCondType,sValue

Function CreateFlow(testSetConditionFactory,sSrcID,sTrgID,sCondType,sValue)
On Error Resume Next
Set oNewCond = testSetConditionFactory.AddItem(Null)
oNewCond.ID = 0
oNewCond.Type = 1
oNewCond.Source = sSrcID
oNewCond.Target = sTrgID
oNewCond.Value = 1
oNewCond.Desc ="Sample"
oNewCond.Post
'oNewCond.Status = "Open"
testSetConditionFactory.Save()

End Function

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TestSet Execution flow in VBA using ALM OTA

Jump to solution

It seems ConditionFactory doesn't accept Null to create a virtual entity.

You may use below way to create and post your conditions:

Set condFactory = theTestSet.ConditionFactory
' Create an array with this order: Type, Source, Target, Value, Desc (This was edited to correct the order)
CondArr = Array(1, 6, 7, 2, "Sample")

condFactory.AddItem(CondArr)
condFactory.Save

By this way, you should be able to create Execution Condition for Test Set.

View solution in original post

Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TestSet Execution flow in VBA using ALM OTA

Jump to solution

' Create an array with this order: Type, Value, Source, Target, Desc, 

The order is not correct in previous post.

It should be: Type, Source, Target, Value, Desc.

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Re: TestSet Execution flow in VBA using ALM OTA

Jump to solution
the above code was not working

script get stuck in this step and stops

condFactory.AddItem(CondArr)
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TestSet Execution flow in VBA using ALM OTA

Jump to solution

My posted code was tested and confirmed. 

Please post your whole pieces of code instead of single line. And you may need provide more information such as ALM version and edition.

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Re: TestSet Execution flow in VBA using ALM OTA

Jump to solution

ALM Version 12.53

UFT Version 14.52

sUserName=xx
sPassword =xx
sDomain =xx
sProject =xx

sCurrSystem = xx

sALM =xx

Set oALMConnection = CreateObject("TDApiOle80.TDConnection")
oALMConnection.InitConnectionEx sALM
oALMConnection.Login sUserName, sPassword

oALMConnection.Connect sDomain, sProject

sSource =xx <source test name>
sTarget =xx<Target test name>

 

Set oTestFactory = oALMConnection.TestFactory
Set oTestSetTreeManager = oALMConnection.TestSetTreeManager
Set oTestSetFolder = oTestSetTreeManager.NodeByPath("xxx">

Set oTestSetFactory = oTestSetFolder.TestSetFactory
Set oTestSetList = oTestSetFactory.NewList("")
For Each oTestSet In oTestSetList

If oTestSet.Name = <testsetname> Then
Set oCurrentTestSet = oTestSet
Set otestFac = oCurrentTestSet.TSTestFactory
Set otestlist = otestFac.NewList("")
Msgbox otestlist.Count
For each tstest in otestlist

Msgbox "ID: " & tstest.ID &"Name: "& tstest.Name & "Status :" & tstest.Status
If tstest.Name = sSource Then sSrcID = Clng(tstest.ID)
If tstest.Name = sTarget Then sTrgID = Clng(tstest.ID)


Next

 

sCondType = Clng(1)
sValue = "TDCOND_PASSED"

Set testSetConditionFactory = oCurrentTestSet.ConditionFactory

CondArr = Array(1,sSrcID ,sTrgID ,sValue ,"")

testSetConditionFactory.AddItem(CondArr )

testSetConditionFactory.Save()

Next

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TestSet Execution flow in VBA using ALM OTA

Jump to solution

Hi @krithika 

The fourth item in the Array is integer as 2 for TDCOND_PASSED instead of string value. Refer to definition tagTDAPI_CONDSTAT .

Quote from ConditionFactory.AddItem
(
3) Value - The condition value. (required). For a time condition, the date-time string. For a run condition, either TDCOND_PASSED  or TDCOND_FAILED.

That's why I highly suggested you to post your code, otherwise it's really hard for others to figure out what happened in your code.

I hope now it resolved your problem.

Thanks,
Mike

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Re: TestSet Execution flow in VBA using ALM OTA

Jump to solution

Thanks a lot mike .

 

It solved my issue and i could implement the Execution flow through vba.

 

Really appreciate your time and effort

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TestSet Execution flow in VBA using ALM OTA

Jump to solution

That's great.

@krithika Can you please mark the comment I posted with sample code as Solution? That will help other people who wants to implement similar feature as you.

"Likes" and "Mark as Solution" are encourages to contributors in the community as well.

Best Regards,
Mike

Highlighted
Regular Contributor.
Regular Contributor.

Re: TestSet Execution flow in VBA using ALM OTA

Jump to solution

Hi Mike ,

I want to delete a TestFolder in Test lab using OTA  if the folder exist

 

i created the below function: -- when i execute the below function using UFT by step through - after i refresh the ALM and check the folder is deleted . but when i execute the same function within vbs file its not working. can you help to suggest a solution

sTestSetLocation = "Root\sample1\subfolder2"

sTestSetFolder = "folder1"

Function RemoveTestSetFolder(oTDC, sTestSetLocation, sTestSetFolder)
On Error Resume Next

Set oTestSetTreeManager = oTDC.TestSetTreeManager
Set oTestSetFolder = oTestSetTreeManager.NodeByPath(sTestSetLocation & "\" & sTestSetFolder)
If (oTestSetFolder Is Nothing) Then
Else
Set oParentFolder = oTestSetTreeManager.NodeByPath(sTestSetLocation)
ChildNode = oParentFolder.FindChildNode(sTestSetFolder)
oParentFolder.RemoveNode(ChildNode)
oParentFolder.Post
oParentFolder.Refresh
Set oRootFolder = oTestSetTreeManager.NodeByPath("Root")
oRootFolder.Refresh
End if


Set oParentFolder = Nothing
Set oTestSetFolder = Nothing
Set oTestSetTreeManager = Nothing
End Function

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.