Forum Discussion

VirginiaSus3's avatar
VirginiaSus3
Occasional Contributor
2 years ago

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:

https://support.smartbear.com/testcomplete/docs/app-objects/specific-tasks/standard/tree-view/checking-item-state.html#Expanded

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

1 Reply

  • 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.