TreeNode expanded or not

Jun 11, 2009 at 1:51 PM


I have a tree and wrote a little helper function.


     /// <summary>
    /// Selects the tree node by given path.
    /// </summary>
    /// <param name="treePath">The path to the node each node seperated by ':'.</param>
    /// <param name="treeID">The tree ID.</param>
    /// <param name="window">The window containing the tree.</param>
    /// <returns>the selected tree node</returns>
    public static TreeNode GetSelectedTreeNode(string treePath, string treeID, UIItemContainer window)
      Thread.Sleep( 100 );
      string[] treePathArray = treePath.Split( ':' );

      Tree tree = (Tree)window.Get( SearchCriteria.ByAutomationId( treeID ) );
      Assert.IsNotNull( tree );
      TreeNode node = catalogTree.Node(treePathArray);

      //node = catalogTree.Node( treePathArray[ 0 ] );


      //for(int i=1; i<treePathArray.Count();i ++)
      //  node = node.Nodes.Where(p => p.Name == treePathArray[ i ] ).First();
      //  node.Select();
      //  if(!node.IsExpanded())
      //  {
      //    node.DoubleClick();
      //  }
      //  node.Expand();

      return node;


TreeNode node = GetSelectedTreeNode("Root:Applications:Application:Static:Parameters"; "automationId", window);


Problem is that the Static node has no elements if I debug, but in fact there are elements in this tree .


Application is not expanded if I call the function, but will be expanded during the call.

Static will not be expanded.


Add the end node.Select throws a NullPointerException


Any ideas?








Jun 11, 2009 at 2:37 PM

Find a solution, but this seems to be a general problem.


Here the way I use it know


TreeNode staticNode = GetSelectedTreeNode("Root:Applications:Application:Static"; "automationId", window);


TreeNode paramNode = GetSelectedTreeNode("Root:Applications:Application:Static:Parameters"; "automationId", window);


now the correct node is selected

Jun 15, 2009 at 5:25 PM

Would it be possible for you to provide application under test code (sample would do) against which this is happening.

Jun 16, 2009 at 6:50 AM

Sorry, I can't :(


I can only say that this is an application which is integrated into Visual Studio 2008.


I can tell something about the test which is done.


I have a tree structure







now I Add a parameter, after that the structure should be







If I now get the Tree element and have a look on the internal structure, I see that there are no elements under static. I had to doubleClick on static first.


If I interpret your question, you think that there is a problem in the tree implementation of the system under test?

Jun 25, 2009 at 4:13 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.