Page 1 of 1

FindControlName with more instances of a control in a Form

Posted: Thu Aug 07, 2008 12:16 pm
by jabelshauser
scenario: in an MDI-Window, there are more Controls with the same control-name
How can i get a list of these controls ? "FindControlName" returns only the actual focused control.
Manually iterating a list of Form.Controls takes too much time, not practicable

Need it for .Net1.1

Posted: Fri Aug 08, 2008 12:50 pm
by Support Team
How many documents do you have in the MDI-Window?
And how many controls in one document?
Form.Controls takes too much time
Form.Controls works normally quickly, but reading the ControlName can take time. How long does it take to find a control by name only in one document (Form)?

Jenö
Ranorex Team

Posted: Mon Aug 11, 2008 11:42 am
by jabelshauser
about 10s, there were about 80 controls in the Form (all about, i don't remember exactly)

Posted: Mon Aug 11, 2008 4:10 pm
by Support Team
about 10s, there were about 80 controls in the Form


10 sec is too long, can you please post your source code.

Please read also the following thread:

http://www.ranorex.com/forum/why-so-slow-t433.html

Can this be the same problem as yours?

Jenö
Ranorex Team

Posted: Tue Aug 12, 2008 8:44 am
by jabelshauser
Enable Caching has no effect.

Here the code:
ArrayList al = _obj.Controls;
Trace.WriteLine("control count = " + al.Count);

foreach(Control ctrl in al)
{
if(ctrl.Name == "frmUiWindow")
Trace.WriteLine(ctrl.Name.ToString());
}
DateTime tstop = DateTime.Now;

Trace.WriteLine("elapsed time = " + (tstop - tstart).ToString());

Trace:
control count = 148
frmUiWindow
frmUiWindow
elapsed time = 00:00:16.6091624

Posted: Tue Aug 12, 2008 3:57 pm
by Support Team
OK, i think the problem is the SleepTime property.

Here is the documentation of the Application.SleepTime property:
Gets or sets the sleep time in milliseconds as an integer value. The current thread will be suspended for the specified sleep time after every command.
You can speed up your scripts with the SleepTime properety.
Please set this property to 0 (Application.SleepTime=0) and try the same code again.

Jenö
Ranorex Team

Posted: Wed Aug 13, 2008 7:20 am
by jabelshauser
ok, the speedtime was the problem.
What's the reasons for such a long default sleeptime ?

Posted: Wed Aug 13, 2008 4:02 pm
by Support Team
What's the reasons for such a long default sleeptime ?
The default SleepTime (50msec) is optimal at the beginning or if you want to follow the automation steps. You can use the SpeedTime as a global variable to control the speed of the automation.
(Please see also Mouse.MoveTime)

Jenö
Ranorex Team