In this lesson, I will present you the selectors in UiPath. A selector is a way to identify User Interface elements on the screen and it has the structure of an XML. Most of the time, the selector is generated automatically by UiPath Studio. Understanding selectors is important because in other cases it has to be manually generated or modified. For example when you want to insert a wild card or a variable into a selector.
Example of selectors
You can find the Selector on the Properties panel of activities. Search for Input > Target > Selector.
To get familiar with the Selectors I recommend playing a little bit with the UI Explorer. Go and launch the explorer tool and select different elements to see how the selector is generated.
Full vs Partial selectors
A full selector contains all the elements needed to identify a UI element, including the top-level window. I recommend using it when switching between multiple windows.
A partial selector doesn’t include the top-level window because it’s already enclosed inside a container that provides the context. The container is usually an AttachWindow or AttachBrowser activity. I recommend using it when you have to perform multiple actions in the same window.
Basic recording generates full selectors, meanwhile Desktop recording generates partial selectors.
|Basic Recording||Full Selectors|
|Desktop Recording||Partial Selectors|
To build dynamic-changing attributes in a selector you must use wildcards. UiPath supports the following 2 wildcards:
- Asterisk (*) – Replaces ANY NUMBER of characters
- Question Mark (?) – Replaces exactly ONE character
To create a dynamic selector you must identify a variable value inside a selector’s attribute. Replace this dynamic value with a variable.
I find this handy when I want to navigate from one page to another.
As you can see the aaname attribute contains the value of the page. The dynamic selector will look like this: