Ask a Question

Using JTree with C# and Test Complete

Occasional Contributor

Using JTree with C# and Test Complete

I am writing a test which accesses a JTree via test complete and C#. I have attached an image. Unfortunately, for company confidentiality I had to black out some of the text. But it is basically the following: FMC 4 ME

Routing Rules

  • Level 2 branches
    • level 3 selections

I get the JTree into a C# var (call it "tree"). I can easily expand and collapse by doing

tree["DblClickItem"]("Routing Rules");  // expand/collapse top branch
tree["DblClickItem"]("Routing Rules|Level 2 branches");  // expand/collapse second-level
tree["ClickItem"]("Routing Rules|Level 2 branches|level 3 selections") // select item

that works fine. But when I try to determine whether something is expanded or not, like this

var expanded = tree["wExpanded"]("Routing Rules");

this gives an exception

  •  _innerException {"Unable to find the object wExpanded(\"Routing Rules\"). See Details for additional information.\r\n<html><body><p>The object with the specified attributes does not exist.</p><p style=\"margin-top: 12px;\"><a href=\"aqa-help://2202\">Possible causes of the error</a></p></body></html>"} System.Exception {System.Runtime.InteropServices.COMException}

this appears to be how this web site says to do it:

Am I doing something wrong? Or can I not assign the value to a "var" and must use it in an if() statement?


Hi @VirginiaSus3,


I wouldn't think wExpand is a property of the tree. It is most likely a property of a treeItem.  So you would want to get the item first, then get the expanded property.


It might look something like this:

var treeItem = tree["wItems"]["Item"]("Routing Rules");

var expanded = treeItem["wExpanded"]; 


or this:

var treeItem = tree.wItems.Item("Routing Rules");

var expanded = treeItem.wExpanded; 


I hope this helps.

Showing results for 
Search instead for 
Did you mean: