Page 1 of 1

Selecting Unidentifiable Controls

Posted: Fri Sep 07, 2007 3:53 pm
by chall
**Situation**
User wants to automate clicking 3 check boxes that are located in various positions on a form, though they share the same screen position, points, or coordinates and visible properties are false.

The 3 check boxes do not have unique IDs or names that would allow user to identify them. As a matter of fact, they share a control ID with a visible button. But in addition to control ID and control type, they have the same role, which is also shared by other controls on the form.

What sets the check boxes apart from the other controls on the form is their handler, though it changes every time the application is restarted. One final significant point is that although there are more that one check box that share the same attributes, it appears the form does not recognize them as separate entities.

I tried using the recorder to generate the code and to determine where I was making my mistake, but it met with the same results as I did: it selected the button instead of the check box.

How do I automate clicking check boxes that do not have a unique control ID or name, dispersed in different sections of a form and whose roles are the same as other controls on the form?

Posted: Fri Sep 07, 2007 4:44 pm
by webops
One suggestion:

You can read all children of the form with the function form.Children:

Code: Select all

foreach (Control child in form.Children)
{
    Console.WriteLine("Handle={0} Text={1}", child.Handle, child.Text);

    if( child is CheckBox )
        Console.WriteLine("  CheckBox Handle={0} Text={1}", child.Handle, child.Text);
}
Jenö
Ranorex Team