ElementDoDefaultAction on a TreeView heading

Class library usage, coding and language questions.
Mike
Posts: 7
Joined: Wed Aug 15, 2007 8:47 pm
Location: Seattle

ElementDoDefaultAction on a TreeView heading

Post by Mike » Mon Nov 05, 2007 6:48 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Mon Nov 05, 2007 10:03 pm

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