Forum Discussion

pcherng's avatar
pcherng
Occasional Contributor
13 years ago

Trouble with finding objects that are part of a JTree

In the tested application, there is a Swing JTree that is normally collapsed. I am able to make TestComplete click on the first node and expand it. When it is expanded, there is a JTextArea displayed for that node. I am trying to access the text that is displayed in that JTextArea. However, TestComplete refuses to recognize that the JTextArea even exists with the Find methods and even in the object browser. The object browser shows that the JTree does not have any JTextArea child objects, even after refreshing over and over. The only way I can get it to show that the JTextArea object exists in the object browser is to record a script of me highlighting some text in that JTextArea, right clicking the mapped name for the object in NameMapping, and selecting "Show in Object Browser," at which point the JTextArea child object magically appears. However, if I collapse and expand the JTree again, the JTextArea child object disappears and does not return and the mapped name no longer can find that object. Is there something I need to do to ensure that the child objects of a JTree can be found after expanding a node?

1 Reply

  • Julia_K's avatar
    Julia_K
    SmartBear Alumni (Retired)

    Hello Paul,


    The Object Browser does not display child items of JTree controls. The Find method does not return JTree items either. This behavior is expected for TestComplete.


    To access child items of tree controls in Java applications, you can use the JTree.wItems property that returns a collection of tree items. To learn how to work with JTree controls, please see the JTree and Working with Tree View Controls Help topics.


    I hope this information helps you.

    Thank you.