Ranorex Blog - Software Automation & Automated Testing Blog

Differences between control and element

Posted by ahoisl on Friday, February 15th, 2008 at 4:59 pm to Test Automation

Every control is made up of a number of smaller elements. Elements are the atoms and controls the molecules of a graphical user interface.

Difference Control Element

Controls are the primary Windows GUI objects which are identified at runtime by a window handle. Every type of control enables some other kind of user interaction at a different level of complexity, e.g. a label just shows some information whereas the more complex ListView may also be used to select an item or display its items in various styles.

The more complex controls (just like the ListView) may be divided into smaller GUI objects that we call elements. An element can, for example, identify the column headers in a ListView or a distinct ListView item. Every element is assigned a role, e.g. “ListItem” or “ColumnHeader”, from a predefined list of possible roles that describe how the user can interact with an element.

Every control also has a corresponding element object, and both controls and elements can contain child GUI objects. Thus, both controls and elements constitute trees of GUI objects, where the element tree has a finer granularity than the object tree.

Control and Element hierarchy

So, in order to automate GUIs you can either use the control or the element approach, but usually you will need both of them to get everything done. For example searching in the control tree is much more effecient than searching for elements because of the smaller number of controls. Even so, you will still need to use elements to click the column header of a ListView.

Share

2 comments

  1. djelloul

    I have nit Unterstand can you pleas Repeat tha yousing Grafik hearachi. form,control,child,element,….
    Even so one VB.net Example

    Thank you
    Djelloul From Germany

  2. ahoisl

    I added a diagram showing the control and element hierarchy.

    Regards,
    Alex

Leave a Reply