Knowledge Base

UI hierarchy, attributes, wildcards

UI hierarchy

The UI hierarchy consists of children and parents, depending on what level of the selector you are looking at. If you ever have problems getting a good selector, you can always add more children or parents.

Let`s have a closer look and analyze the selector of the editable field inside a Notepad file.

The first row identifies the application and the actual window we are working with. In our case, the application is notepad.exe, the class is notepad and the title of the notepad file is “Untitled – Notepad”.

The next two rows identify our control in the application window hierarchy.
Some programs have a volatile layout – because of nodes with unsteady attribute values; as in the case of web-apps, but not only – which make automatic generation of reliable selectors impossible.

UiPath can't always predict how an attribute's value will change along the runtime, or between runs of an app, but there are workarounds for this.
For example we notice that UiPath recognizes the notepad window by its title:
title='Untitled - Notepad'
However, that title can change very easily. The solution to this problem is to:
• build better selectors
• in our case modify the title attribute using the * wildcard:
title='*- Notepad'

Selector attributes

On the right side of the UiExplorer screen we have the selector attributes.

The current attributes part contains all the attributes of an object. Not all can be added or removed from your selector string, because not all of them are useful for identifying a certain object.

The most important thing when choosing selectors is to pick those which always have a constant value. If the value of an attribute changes, then the selector will not be able to correctly identify the element.

Wildcards: * and ?

Attributes may change their values from time to time when the application's UI changes. When this happens, part of the dynamic attributes often remain unchanged and we somehow have to specify the variable parts. This can be done using wildcards:

1. * star means zero or more characters can be there. Example: title='* - Notepad'.
2. ? question mark means exactly one character. Example: title='Expl?rer'.

A direct consequence when using wildcards is the increased probability of there being more and more nodes matching the Selector. That's why, in order to uniquely identify a node, we might have to add an idx attribute.

First example: We have two windows with the following titles: Report and Status . The variable parts can easily be noticed. We want to choose the second value, and somehow our original identifier <wnd cls='AfxWnd' title='Status 7/10/2010'/> doesn't work anymore. We can reach it using wildcards such as: <wnd cls='AfxWnd' title='Status *'/>.

Second example: we have three windows with the following titles: Report , Status and Status . We can reach the third window with: "<wnd cls='AfxWnd' title='Status *' idx='2'/>".

Most attributes support wildcards.