This topic explains the concept and specifics of the Tree model of web test objects. For the general principles of web object identification, see About Web Object Identification and Object Models.
The Tree model represents web page objects in a tree-like structure that reflects the nesting of HTML elements in the page markup. For example, suppose a web page contains a table with an input field. In the Tree model, it is represented as a
Table object that has a child
Cell object with a child
The Tree model is recommended for web testing and is used by default in all new TestComplete projects. It is also more full-featured than other models. For example, the cross-browser
contentText property for getting the element contents is supported only in the Tree model.
If you use Name Mapping, the names used to refer to web page objects from tests are specified in Name Mapping. For example, the full name of a user name input field on a web page titled “Example” can be as follows:
You can modify the default generated names to make them more descriptive. For more information, see Addressing Web Objects Using Name Mapping and Aliases.
In the Object Browser and in tests where Name Mapping is not used, object names are formed in accordance with the following rules:
ObjectType takes one of the values listed in the Object Types Used in the Tree Model topic. Note that they are not the same as the tag names. For example, the A elements (links) have
ObjectType of Link.
CustomObjectType value is based on the name under which the custom element is registered in the web application. To learn more, see About Support for Web Components.
ObjectIdentifier has of the following values (in the order of precedence):
For Image objects (
<img> elements) - the object’s
namePropStr property value which holds the last component of the src URL (typically the file name).
For Button (
<input type="button">), ResetButton (
<input type="reset">) and SubmitButton (
<input type="submit">) - the
For Area objects (
<area> elements) - the area’s
title attribute value.
For other objects - the object’s
name in the HTML code, changed as follows:
The project’s Identification attribute setting specifies which attribute -
name - is used first.
The object’s zero-based index among the sibling objects of the same type.
The names of table cells have the following format:
Cell(RowIndex, ColumnIndex), where RowIndex and ColumnIndex are the cell’s row and column numbers (zero-based) in the table.
Some elements (for example hidden INPUT fields) are not displayed. See Web Elements Included in and Excluded From the Tree Model for a full list.
Since the Tree model reflects logical nesting of web page elements, the fully-qualified names of objects on web pages with complex markup can be quite long. For example:
// Using Name Mapping
// Not using Name Mapping
Such long object names can make your tests difficult to read.
There are several ways to avoid long object names in tests:
If you use Name Mapping, you can use the Extended Find feature to identify target objects while skipping intermediate hierarchy objects. TestComplete automatically uses Extended Find for new web objects added to Name Mapping if the Use extended find when possible option is enabled. For more information, see Extended Search.
If you use keyword tests, you can use the Maximum depth option to control the number of displayed hierarchy levels (that is, intermediate levels will not be displayed). Note that when editing keyword test operations, you see the full object hierarchy.
Testing Web Applications
About Web Object Identification and Object Models
Web Object Types Used by the Tree Model and Hybrid Mobile Applications
Accessing DOM document Object