Ranorex

Element-Class Performance

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet
View previous topic :: View next topic  
Author Message
Kosmo



Joined: 06 Oct 2007
Posts: 3

PostPosted: Sat Oct 06, 2007 10:21 pm    Post subject: Element-Class Performance
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: click into code to enlarge
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
Back to top
View user's profile Send private message
Kosmo



Joined: 06 Oct 2007
Posts: 3

PostPosted: Mon Oct 08, 2007 12:07 am    Post subject:
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
Back to top
View user's profile Send private message
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 435

PostPosted: Mon Oct 08, 2007 1:13 pm    Post subject:
Quote:
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: click into code to enlarge
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: click into code to enlarge
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: click into code to enlarge
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: click into code to enlarge
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);
}


Quote:
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
Back to top
View user's profile Send private message Visit poster's website
Kosmo



Joined: 06 Oct 2007
Posts: 3

PostPosted: Mon Oct 08, 2007 7:42 pm    Post subject:
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. Confused

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. Sad
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
Back to top
View user's profile Send private message
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 435

PostPosted: Tue Oct 09, 2007 12:08 am    Post subject:
Quote:
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: click into code to enlarge
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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum