There are some window applications that contain a "Tree" structure of elements using "Tree Items"


In these cases, it is by design that when a Tree Item is captured, the UISpy gets the Tree selector (instead of the Tree Item selector) with the Tree Item path as metadata for the "Folders Path" input in the "Expand/Collapse Tree Node in Window" action. 



As a result, the generated selector is incomplete, which is OK if you want to use the aforementioned action, but could be an issue in case you want to use other UI actions.


If the element we want to use contains more sub-elements, then an option would be to use the "Expand/Collapse Tree Node in Window" action, which uses the first (incomplete) selector and the path "/Desktop/This PC/Downloads" to the Tree Item. That way, the action will expand or collapse the node and select it at the same time, but it cannot work on a Tree Item that cannot expand/collapse.


Hence, a custom Selector would be required.


Let's have a look at the following example:


In the above scenario the selector that is automatically generated is:

> window[class="#32770"][name="Save As"] > pane[class="DUIViewWndClassName"] > pane[class="ProperTreeHost"][id="ProperTreeHost"][name="Control Host"] > tree[class="SysTreeView32"][name="Tree View"]


By manually adding "> treeItem[name="Desktop"] > treeItem[name="This PC"] > treeItem[name="Downloads"]" in the end, the selector will be complete and the element "Downloads" can be handled.