Page 1 of 1

ElementDoDefaultAction on a TreeView heading

Posted: Mon Nov 05, 2007 6:48 pm
by Mike
Hi,

I have a winXP SP2 box. In the app I'm testing I have a SysTreeView32 control that contains a number of elements. The default action on these elements is Expand. I'm trying to expand the element by using ElementDoDefaultAction.

Code: Select all

element = Ranorex.ControlGetElement(control)
      treeViewHeading = Ranorex.ElementFindChild(element, 36, heading, "SysTreeView32")
      position=Ranorex.ElementGetPosition(treeViewHeading)
      if element != None: 


          print "Found the tree view control"
      else:
          print "Can't find tree view control"
    
          return -3
     
      if (position != None and position[0] != 0 and position[1] != 0):

          #Works
          Ranorex.MouseMoveToElement(treeViewHeading)
          #Works
          Ranorex.MouseClickElement(treeViewHeading)
          #Fails
          Ranorex.ElementDoDefaultAction(treeViewHeading)
I can move the mouse to the element using this code and I can click on the element using this code but when I try and expand the element it silently fails. How can I expand the treeview elements?

Thanks,
Mike

Posted: Mon Nov 05, 2007 10:03 pm
by Support Team
Please read the topic:

http://www.ranorex.com/forum/locating-a ... w-t95.html

behdad made the following (C# code):

Code: Select all

protected void TreeNodeExpand(Element folder) 
{ 
  // Check to see if the node is collapsed then expand it 
  if ((folder.State & State.Collapsed) != 0) 
  { 
    // Double click the folder 
    ElementDoubleClick(folder); 

    // Wait for it to get expanded 
    while ((folder.State & State.Collapsed) != 0) 
    { 
      // Wait 
      Wait(Constants.TIMEOUT_TINY); 
    } 
  } 
} 
Jenö
Ranorex Support Team