I found a workaround in an old thread:
http://www.ranorex.com/forum/locating-a-folder-in-treeview-t95.html
I tried it with the sample VS2005Application and it worked for me.
(I changed the node "SecondNode - FirstChild" to "Second/Node - FirstChild")
Can you please try the following code:
Code: click into code to enlarge
TreeView treeView = form.FindTreeView("treeView1");
LocatePath(form, treeView, @"SecondNode\Second/Node - FirstChild");
static void LocatePath(Form form, TreeView treeView, string path)
{
// Break down the path
string[] folderList = path.Split(@"\".ToCharArray());
// Locate the path
bool ret = Locate(treeView, folderList);
}
static bool Locate(TreeView treeView, string[] folderList)
{
// Get the root tree view element in the control
// The tree view itself has the role Role.Outline
Element treeElement = treeView.Element.FindChild(Role.Outline);
// Get the count of the children
int childCount = treeElement.GetChildCount;
// Traverse the tree
int level = 0;
for (int i = 0; i < childCount && level < folderList.Length; i++)
{
Element node = treeElement.GetChild(i);
if (node == null)
break;
if (node.Name == folderList[level])
{
node.Select(Selection.TakeFocus | Selection.TakeSelection);
Mouse.MoveToElement(node);
treeView.SendKeys("{RIGHT}");
if (level == folderList.Length - 1)
return true;
else
level++;
}
}
return false;
}
Jenö
Ranorex Support Team |