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
- TreeManager : for finding the parent folder
- 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.
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
LikeLike