Is there a faster way to cause the default action and get information of a button with a specific index?
First suggestion:
The function GetChild() can be slow if the Control has a lot of elements.
I would suggest to use the functions FindChildren and FindChildrenValue().
You can read all PushButtons of a control as follows:
Code: Select all
Int32 count = 0;
Element[] buttons = control.Element.FindChildren(Role.PushButton);
foreach (Element button in buttons)
{
Console.WriteLine("{0} Button Name={1})", count++, button.Name);
}
Or you can read all elements of a treeview with value==1 as follows:
Code: Select all
Element[] value1Elements = treeView.Element.FindChildrenValue("1", SearchMatchMode.MatchExact);
Int32 count = 0;
foreach (Element treeItem in value1Elements)
{
Console.WriteLine("{0} Item Name={1})", count++, treeItem.Name);
}
Or you can read all elements with value ==1 or 2, 3 as follows:
Code: Select all
Element[] value123Elements = treeView.Element.FindChildrenValue("[1-3]", SearchMatchMode.MatchRegExp);
Second suggestion:
You can also set the StaticProperties of the Element class to true if the properties are static.
Try the following sample with the WindowsExplorer:
It works very quickly for me.
Code: Select all
Form form = Application.FindFormClassName("ExploreWClass");
// Find TreeView by control id
TreeView treeView = form.FindTreeView(100);
// Find ListView by control id
ListView listView = form.FindListView(1);
Element.StaticProperties = true;
Int32 count = 0;
Element[] treeItems = treeView.Element.FindChildrenValue("[1-5]", SearchMatchMode.MatchRegExp);
foreach (Element item in treeItems)
{
Console.WriteLine("{0} Item Name={1})", count++, item.Name);
}
Element[] listItems = listView.Element.FindChildren(Role.ListItem);
foreach (Element item in listItems)
{
Console.WriteLine("{0} Item Name={1})", count++, item.Name);
}
Or is the pro version of Ranorex significant faster?
Some of the functions are only supported only in the Pro version.
Jenö
Ranorex Support Team