Absent Member.. bobando Absent Member..
Absent Member..

QTP/UFT Support Tip: How to expand all nodes in a JavaTree programmatically?

Hello everyone,


The JavaTree object in QTP/UFT does not have a built in method to expand all nodes at once, in case it is necessary to expand all node in a Java tree. The following code can be used to expand all nodes from a JavaTree starting from the root:


Set jtree = JavaWindow("javawindow").JavaTree("javatree")
i = 0

itm = jtree.GetItem(i)
jtree.Expand itm
i = i+1
allNodes = jtree.GetROProperty("items count")
Loop Until CInt(i) = CInt(allNodes)

To use the code it is only necessary to change the first line to reflect the correct Java objects for identification based on the application under test.


Note: The above code is not part of QTP/UFT and is provided as-is without guarantee that it will work in every situation, thus HP is not responsible for supporting it or any modifications it may need to suit specific requirements.



HP | Unified Functional Testing Engineer

[If this post or any other post helps to resolve your issue or query, mark the thread as solved and give KUDOS to the author for their assistance. ]

(Posts and opinions made here are my own and do not reflect the opinions of my employer HP in any way)
Labels (1)
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.