# Selector Configuration

For a software robot to simulate specific actions in a user interface (operating system, applications, web pages), it needs to interact with various windows, buttons, dropdown lists, hyperlinks, and so on. In actions with screen forms, Sherpa RPA searches (iterates) for the positions of elements on the screen. Selecting the right element on the screen is a complex task, as the search may involve several thousand elements present on the screen. Often, the identifiers of control elements that can be used to find them on the screen (names, labels, system properties, and descriptors) are subject to dynamic changes; for example, the title of a web page may change during the automation process.

To address this issue, the Designer uses so-called "Selectors." Selectors store the attributes of a graphical user interface element as a set of instructions in XML format, which guide the robot on how to find a specific control element on the screen.

In most cases, selectors are automatically generated by the Designer during the recording of user actions and do not require additional input from the user, especially if the automated applications have a static user interface.

<figure><img src="https://3199517203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4mXXYsqBuhj7RyX6Y4Yw%2Fuploads%2Fgit-blob-777fa17d2090f72366794d72dd5ab8a03ada61ef%2Fimage%20(148).png?alt=media" alt=""><figcaption></figcaption></figure>

**Selector** – a hint, a guide for the robot on how to find a specific control element on the screen. The robot automatically records these selectors when recording any actions.

However, some applications use variable layouts and attributes with changing values, such as in web applications. The Designer cannot predict these changes, so some selectors may need to be created or edited manually.

<figure><img src="https://3199517203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4mXXYsqBuhj7RyX6Y4Yw%2Fuploads%2Fgit-blob-b7c79e31b2a87cb5b400663c13cb2c129f5dc3c3%2Fimage%20(147).png?alt=media" alt=""><figcaption></figcaption></figure>

## **Edit Selector Window**

The "Edit Selector" window is invoked from the right properties panel of the selector (only for those blocks that have selectors) by clicking the button with ellipsis. All blocks related to graphical elements have this property. The selector is available both when Blocks are added to the Project using the "Record" tool and in ready-made blocks for operations with screen forms (UI Automation) from the palette.

The "Edit Selector" window allows you to view the automatically generated selector and modify the selector and its attributes. You can include or exclude certain attributes or add wildcards to dynamically changing values.

When you click the button with ellipsis to the right of the "Selector" field, the selector editing window will appear.

<table data-header-hidden><thead><tr><th width="104"></th><th width="245"></th><th></th></tr></thead><tbody><tr><td><strong>No.</strong></td><td><strong>Interface Element</strong></td><td><strong>Description</strong></td></tr><tr><td>1.</td><td>button “Convert UiPath Selectors…”</td><td>Allows you to open a window to input text from the Selector field of the UIPath activity.</td></tr><tr><td>1.1.</td><td>button <img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeU5XOKxdixXFJw3rPuUFD8cZpF4UulMjnL2NVSVpa60-EYLgMvDU8oEKwZWuo8-_Vq4k8--Iom4ivb3GajuIT0Bez4ZUg2cJdqRe9dPX91IUp_RyQ1Hm5gn0U14Qm3z2l73q36YDEyqbhfm62zbRXO27sk?key=QcJUoh8mLAmXqxEVD8uJXA" alt=""></td><td>Allows you to switch the UIPath operating mode.</td></tr><tr><td>3.</td><td>button “Add New Row”</td><td>Allows you to add a new row.</td></tr><tr><td>4.</td><td>button “Delete Row”</td><td>Allows you to delete the selected row.</td></tr><tr><td>5.</td><td>button “Paste from Clipboard”</td><td>Allows you to paste information from the clipboard.</td></tr><tr><td>6.</td><td>button “Open Sherpa Explorer”</td><td>Allows you to open .Sherpa Explorer</td></tr><tr><td>7.</td><td>button “Insert Modifier”</td><td><p>Allows you to insert a modifier, which can be selected from a dropdown list. Possible options:</p><ul><li>? (any single character);</li><li>* (any number of characters);</li><li>xpath: (XPath processing);</li><li>regex: (Regex processing).</li></ul></td></tr><tr><td>8.</td><td>button “Insert Variable”</td><td>Allows you to insert a variable from those defined in the diagram, which can be selected using a dropdown list.</td></tr><tr><td>9.</td><td>button “Record”</td><td>Allows you to start the selector recording procedure.</td></tr><tr><td>10.</td><td>button “Check”</td><td>Allows you to check the positioning of the element specified in the selector.</td></tr><tr><td>11.</td><td>button “Highlight”</td><td>Allows you to “highlight” (indicate) the last element of the selector.</td></tr><tr><td>11.1.</td><td>button <img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXeU5XOKxdixXFJw3rPuUFD8cZpF4UulMjnL2NVSVpa60-EYLgMvDU8oEKwZWuo8-_Vq4k8--Iom4ivb3GajuIT0Bez4ZUg2cJdqRe9dPX91IUp_RyQ1Hm5gn0U14Qm3z2l73q36YDEyqbhfm62zbRXO27sk?key=QcJUoh8mLAmXqxEVD8uJXA" alt=""></td><td>Allows you to highlight the path (i.e., each line of the selector). This button allows you to see how the selector is being searched in the window interface.</td></tr><tr><td>12.</td><td>button “Delete Selector”</td><td>Allows you to delete the selector.</td></tr></tbody></table>

<figure><img src="https://3199517203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4mXXYsqBuhj7RyX6Y4Yw%2Fuploads%2Fgit-blob-f1d46ca9521e638b8c8ca4141822873aaa22e643%2Fimage%20(149).png?alt=media" alt=""><figcaption></figcaption></figure>

In this window, you can see what the selector looks like, check and correct it if necessary, as well as enrich the selector with auxiliary tools, such as inserting wildcards or inserting the value of a variable. You can also delete unnecessary rows or clear unnecessary cell values.

Thus, a selector is a table consisting of columns and rows, where each row represents a command, a step that the robot must perform. Commands are read from top to bottom. The top row is executed first, and the bottom row last. The robot goes through the steps from top to bottom and executes each row as a command. It searches the screen for an element whose properties all match those specified in the columns of the selector row.

For example, consider the first row of the selector, where:

* Type – process. That is, this row searches for the required application to launch.
* The process name here is – Calculator, written as it appears in the task manager.

<figure><img src="https://3199517203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4mXXYsqBuhj7RyX6Y4Yw%2Fuploads%2Fgit-blob-2d8b93dd3d540013d4e998e9be64c584b429833f%2Fimage%20(150).png?alt=media" alt=""><figcaption></figcaption></figure>

So, at the first stage, the robot will find the process named Calculator among the running processes in the computer's memory.

The next row is designated as UIElement, which is already a window or some specific control element of this selector. To find the required control element, the robot will simultaneously look for an element with the name Calculator, the specified class name, and the control element Window, making it clear that it is referring to a window. This row allows you to find the specific calculator window.

Moving down to the next row. Now, in the found window, it is necessary to sequentially find all the containers that will lead to the required button. There are three such containers here. These containers may not be visually displayed in the application, as they were created for developers. However, from the name “Numeric Panel,” one can guess that this is a container containing all the calculator buttons. And further, we see that the very last element is the digit 6, which the user clicked.

The button "**Check**" checks the positioning of the element specified in the selector, meaning that the Check can return two states:

* Error during check

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXe2xLoGirjfMaMRznbU-16_QpuPtYbyJ4JwdTGOcmV3COLh8frIAM0FiEnCsk5Vksf0r-eLQ5dVyNlUJukTblSH46pV4ByCK6cyrcxE9zWQg6xz9GXvgwafcr2A8t15rE0Yn3VDX_Pc0VO9mc3IwoXGsRcy?key=QcJUoh8mLAmXqxEVD8uJXA" alt=""><figcaption></figcaption></figure>

* Check was successful, the element with the position specified in the Selector was found on the screen.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXdy76SNBB0sntIUViZzmmy9nyFoBwAuLBsmcW36-C63ngLY5AVZp0QFycu81vPxJ1957gD-xLWmbYlj5hNhDL2y9LXkdtN0y7WFueRmgFdCEUc0VcmkYzLleFvXQU1NcwKbhnDUDsdjOJz4mgr6slBX9Vep?key=QcJUoh8mLAmXqxEVD8uJXA" alt=""><figcaption></figcaption></figure>

The button "**Highlight**" – indicates the user interface element, highlighting the element itself and the top-level elements on the path to it with red frames. The highlighting disappears automatically after a few seconds.

The button "**Record**" – starts the procedure for recording the Selector by clicking on the required control element on the screen.

Go to the Selector and click "Record." The **SherpaDesigner** window (with the "Edit Selector" window open) minimizes. A hint for working in Record mode will appear at the top of the screen. Choose the required action for your business process, that is, the required element on the screen, and click on it. Note that the elements should be highlighted before clicking (i.e., a red frame should appear).

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXd_DYBBQ3OPhjyFt4M9bO0UsEgxhcdjWRrwxvy7yk71TVFh8ed_129s0hHy49zueYcI6Hws-DcHylVecYHG8m2mRnyWDWczyZwsUHiJ_plp4IeJrbTDUG65Kn0wqODnubrZdE0CLEc6FXxR0-lVY7RaQeYM?key=QcJUoh8mLAmXqxEVD8uJXA" alt=""><figcaption></figcaption></figure>

If the highlighting does not appear automatically or disappears, to highlight the required element, you need to press the Shift key on the keyboard. Highlighting is needed to accurately select the element under the mouse.

Options for recording a click:

* click the left mouse button;
* press the left Ctrl, which emulates a left mouse button click;
* press the right Ctrl, which emulates a right mouse button click, that is, in many applications, it calls the context menu;
* emulation of the mouse cursor delay over the element is recorded using the Shift key.

**Note:** *only one action (click, paste, hover over a button, etc.) is recorded from the “Edit Selector” window, unlike using the recording tool through the main menu, where you can record multiple actions at once. That is, after performing an action (click), the user automatically returns to the “Edit Selector” window.*

After returning to the Selector editing window, it is recommended to use the "Highlight" or "Check" buttons to verify if the element is correctly selected. If the element is incorrectly selected, you can retry by clicking the Record button or find and correct the error in the Selector rows manually.

## **Configuring the Selector**

<figure><img src="https://3199517203-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4mXXYsqBuhj7RyX6Y4Yw%2Fuploads%2Fgit-blob-2d8b93dd3d540013d4e998e9be64c584b429833f%2Fimage%20(150).png?alt=media" alt=""><figcaption></figcaption></figure>

Each row of the selector has one or more attributes that help correctly identify the exact location of the selected area on the screen. The attributes display which program is being recorded, in which window and element, as well as the specific level of the selected element using attributes such as Type, Name, ClassName, ControlType, Index, Id, Text. Each attribute can have an assigned value by which the search will be conducted. It is important to choose attributes with constant values. If the value of an attribute changes with each launch of the application, the selector will not be able to correctly identify the element. In this case, it is recommended to refrain from using this attribute (leave its value empty).

<table data-header-hidden><thead><tr><th width="100"></th><th width="169"></th><th></th></tr></thead><tbody><tr><td><strong>No.</strong></td><td><strong>Attribute</strong></td><td><strong>Attribute Description</strong></td></tr><tr><td>1.</td><td>Type</td><td>Type of element.</td></tr><tr><td>2.</td><td>Name</td><td>Name of the element.</td></tr><tr><td>3.</td><td>ClassName</td><td>Name of the element's class.</td></tr><tr><td>4.</td><td>ControlType</td><td>Type of control element (e.g., button, text box, etc.).</td></tr><tr><td>5.</td><td>Id</td><td>Identifier of the element (usually unique for each element).</td></tr><tr><td>6.</td><td>Index</td><td>Index of the element in the list of matching elements.</td></tr><tr><td>7.</td><td>Text</td><td>Text inside the element.</td></tr></tbody></table>

Additionally, in complex cases, you can use wildcard characters or substitute the value of an attribute or part of an attribute from a variable:

* Asterisk (\*) replaces any number of characters in the attribute value;
* Question mark (?) replaces a single character in the attribute value;
* $VariableName – using a variable name starting with the $ symbol allows you to insert the value of this variable instead of the attribute value or its part.

## Video Demonstration of Working with Selectors

* Recording selectors: overlapping or invisible elements using the Chrome login window

{% embed url="<https://sherparpa.ru/ucontent/?09>" %}

* Working with selectors in the Chrome "Downloads" window

{% embed url="<https://sherparpa.ru/ucontent/?42zd>" %}

* Recording selectors of a popup window in Internet Explorer

{% embed url="<https://sherparpa.ru/ucontent/?LSpu>" %}

* Converting UIPath selectors to Sherpa RPA in the "Edit Selector" window

{% embed url="<https://sherparpa.ru/ucontent/?gHJc>" %}

* Working with the "Highlight Path" function in the "Edit Selector" window

{% embed url="<https://sherparpa.ru/ucontent/?gMbc>" %}

A comprehensive guide to working with web selectors can be found [here](https://docs.sherparpa.ru/en/sherpa-rpa/sherpa-designer/rabota-v-sherpa-designer/rukovodstvo-po-veb-selektoram).
