|Control properties / Secondary properties|
<ta class> <index>Some examples: treenode 6, div 1, link 12.
The difference is the basis of the index. The global pos properties of controls are essentially anchored to the window, as index values (within a given class) start at 1 in the window and continue to increment. That can be a problem in a dynamic environment, where controls of a given class may come and go. This is especially the case with web applications.
The following figure, depicting a dynamic AUT window at two different points in time, illustrates the value of anchor pos over global pos:
As shown, use of global pos to identify the text block controls is unreliable if it is possible for other controls of the same class to be introduced or removed. Here, a second text block introduced under tree node A has the effect of changing the global pos value of the text block below it in the hierarchy (as well as all other text blocks below it). By contrast, the anchor pos value of the lower text box, based on the anchor being the parent tree node, remains constant.
As a general rule, when using anchor / anchor pos to identify a control, it is best that your anchor be an ancestor which is as close as possible to the control of interest. The tradeoff is that you must also find an anchor control which is truly "anchorable" – that is, one that can itself be reliably and uniquely identified, either through a unique set of property-value pairs, or possibly even by being anchored to still another control (multilevel anchoring). The above example, for instance, assumes that we have some reliable means of uniquely identifying tree nodes A and B, allowing them to be used an anchors for their child text blocks.