Element-Class Performance

Class library usage, coding and language questions.
Kosmo
Posts: 3
Joined: Sat Oct 06, 2007 8:50 pm

Element-Class Performance

Post by Kosmo » Sat Oct 06, 2007 9:21 pm

Hello,

I use the free version of Ranorex library in a csharp project.

The test application contains many elements (> 400). This elements are identified from RanorexSpy as PushButtons.
To test is a (long) sequence of clicks/default actions with this buttons.

I get a button with GetChild methods to prevent slow "find" methods:

Code: Select all

Element button = form.Element.GetChild(indexContainer)
                 .GetChild(row).GetChild(column);
button.DoDefaultAction();
The direct way with indeces is okay for this case, but still to slowly for me.
One "click" needs mostly 1-2 seconds.

Past the click also I need information of the button element .. to get the name costs extra 1-2 seconds.

Is there a faster way to cause the default action and get information of a button with a specific index? Or is the pro version of Ranorex significant faster?

Greetings,
Kosmo

Kosmo
Posts: 3
Joined: Sat Oct 06, 2007 8:50 pm

Post by Kosmo » Sun Oct 07, 2007 11:07 pm

Hello again,

during test I noticed that element actions get very faster (0.1 seconds per action) if the main window of the test application is overlap with a modal dialog.

Is it possible to force this behavior?

Thanks in advance for any ideas.

Greetings,
Kosmo

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 Oct 08, 2007 12:13 pm

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

Kosmo
Posts: 3
Joined: Sat Oct 06, 2007 8:50 pm

Post by Kosmo » Mon Oct 08, 2007 6:42 pm

Hello,

thank you for the answer.
Support Team wrote:The function GetChild() can be slow if the Control has a lot of elements.
I would suggest to use the functions FindChildren and FindChildrenValue().
Find-Methods should be faster than Get? That's surprised me, but ok. I have test it now and the time need is similar to the Gets. :?
Support Team wrote:You can also set the StaticProperties of the Element class to true if the properties are static.
Mm.. very interesting. Unfortunately in my case the name of the elements are not static. :(
They contains changing informations that I need for validating.

What about the modal dialog (my second post)?
If there a modal dialog, it's fast enough for me. But why?
I think it's when the main form doesn't accept user input.
Is it possible to force the form in a similar state while gui testing?

Greetings,
Kosmo

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 Oct 08, 2007 11:08 pm

What about the modal dialog (my second post)?
The difference is, that a modal dialog box has its own message loop, which has no interaction with the application's main message loop. A modal dialog box uses the Dialog Manager (the code built into Windows for implementing dialog boxes) to retrieve messages from the application's message queue and process them.

Please try the following:

Code: Select all

Element.StaticProperties = true;
Element[] items = control.Element.FindChildren(Role.PushButton);
foreach (Element element in items)
{
    Console.WriteLine("Count={0} Name={1} Position={2}", 
                       count++, element.Name, element.Location);
}
I will analyse this issue if you send me a sample application.

Jenö
Ranorex Support Team