Ancestor Method
The Ancestor method searches upwards in the hierarchy to find an ancestor component with a set of properties that make it unique. This ancestor component can't be part of an ascending hierarchy that is incorrectly recognized.
With this method, you need to:
-
Declare an item that targets this ancestor component
-
Set this item as an ancestor of your item when you set item parameters (see Item Definition)
The target component will be searched in the descendance of the ancestor component.
Consider this use case:
In the following DOM, you want to target second leafnode (in orange):
The two leafnodes are the same, so, if you don’t use the Ancestor method, the first leafnode will always be recognized, not the second. You cannot use node (id=1) as ancestor, because it is ancestor of both of the leafnodes and the first leafnode will be recognized. So I must use subnode (id=3) as ancestor so that the second leafnode is recognized.