Find folders under test plan folder in ALM using OTA API

In this post, we will discuss how to find child folders under test plan folder in ALM Using OTA API. We will use C# for this post.

For finding child folders under a test plan folder we will use the following objects

  1. TreeManager : for finding the parent folder
  2. SysTreeNode : For finding the child folders

First, we will find the SysTreeNode Object for parent folder path

TDAPIOLELib.TreeManager OTManager = tDConnection.TreeManager;
TDAPIOLELib.SysTreeNode OSysTreeNode = OTManager.NodeByPath[folderPath];

Where tDConnection is the ALM Connection object. You can read about it here.

Once we have the SysTreeNode object then we can loop it to get the child folder names

for (int Counter = 1; Counter <= OSysTreeNode.Count; Counter++)
{
Console.WriteLine(OSysTreeNode.Child[Counter].Name);
}

Below is the complete code

public List<String> GetChildFolderNames(String folderPath)
{
List<String> OFNames = new List<string>();
TDAPIOLELib.SysTreeNode OSysTreeNode = GetNodeObject(folderPath);
for (int Counter = 1; Counter <= OSysTreeNode.Count; Counter++)
{
OFNames.Add(OSysTreeNode.Child[Counter].Name);
}
return OFNames;
}

public TDAPIOLELib.SysTreeNode GetNodeObject(String folderPath)
{
TDAPIOLELib.TreeManager OTManager = tDConnection.TreeManager;
return OTManager.NodeByPath[folderPath];
}

To find the child folders inside “Subject\Dummy1”. We can call the function like this

List<String> list = GetChildFolderNames("Subject\\Dummy1");

foreach (String folderName in list)
{
Console.WriteLine("Folder Found under Subject\\Dummy1 : " + folderName);
}

Let me know if you have any questions in Comments.

Advertisement

One response to “Find folders under test plan folder in ALM using OTA API

  1. Hi Sumeet, Thanks a lot for your well written articles.
    I have a question. In the above code sample, how can I find test case IDs, under a specific folder?… If you could throw some light it would be a great help

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s