Chapter - 9 Selectors

24 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€95.86
List Price:  €134.21
You save:  €38.35
£79.54
List Price:  £111.35
You save:  £31.81
CA$143.56
List Price:  CA$200.99
You save:  CA$57.43
A$159.95
List Price:  A$223.94
You save:  A$63.98
S$135.54
List Price:  S$189.77
You save:  S$54.22
HK$777.41
List Price:  HK$1,088.41
You save:  HK$310.99
CHF 89.37
List Price:  CHF 125.13
You save:  CHF 35.75
NOK kr1,131.89
List Price:  NOK kr1,584.70
You save:  NOK kr452.80
DKK kr715.08
List Price:  DKK kr1,001.15
You save:  DKK kr286.06
NZ$176.78
List Price:  NZ$247.50
You save:  NZ$70.72
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳11,900.85
List Price:  ৳16,661.67
You save:  ৳4,760.81
₹8,494.03
List Price:  ₹11,891.98
You save:  ₹3,397.95
RM450.75
List Price:  RM631.07
You save:  RM180.32
₦154,505.46
List Price:  ₦216,313.83
You save:  ₦61,808.36
₨27,720.51
List Price:  ₨38,809.83
You save:  ₨11,089.31
฿3,419.79
List Price:  ฿4,787.84
You save:  ฿1,368.05
₺3,506.82
List Price:  ₺4,909.70
You save:  ₺1,402.87
B$608.53
List Price:  B$851.97
You save:  B$243.44
R1,831.63
List Price:  R2,564.36
You save:  R732.72
Лв187.37
List Price:  Лв262.33
You save:  Лв74.95
₩144,627.53
List Price:  ₩202,484.33
You save:  ₩57,856.80
₪363.83
List Price:  ₪509.39
You save:  ₪145.55
₱5,882.91
List Price:  ₱8,236.31
You save:  ₱2,353.40
¥15,642.93
List Price:  ¥21,900.73
You save:  ¥6,257.80
MX$2,007.92
List Price:  MX$2,811.18
You save:  MX$803.25
QR363.05
List Price:  QR508.28
You save:  QR145.23
P1,376.48
List Price:  P1,927.13
You save:  P550.64
KSh12,857.29
List Price:  KSh18,000.72
You save:  KSh5,143.43
E£5,087.81
List Price:  E£7,123.14
You save:  E£2,035.32
ብር12,414.52
List Price:  ብር17,380.83
You save:  ብር4,966.30
Kz91,790.82
List Price:  Kz128,510.82
You save:  Kz36,720
CLP$98,780.55
List Price:  CLP$138,296.72
You save:  CLP$39,516.17
CN¥729.56
List Price:  CN¥1,021.42
You save:  CN¥291.85
RD$6,064.47
List Price:  RD$8,490.50
You save:  RD$2,426.03
DA13,486.35
List Price:  DA18,881.43
You save:  DA5,395.08
FJ$231.62
List Price:  FJ$324.28
You save:  FJ$92.66
Q767.35
List Price:  Q1,074.32
You save:  Q306.97
GY$20,835.60
List Price:  GY$29,170.68
You save:  GY$8,335.07
ISK kr13,848.23
List Price:  ISK kr19,388.08
You save:  ISK kr5,539.84
DH1,002.31
List Price:  DH1,403.28
You save:  DH400.96
L1,836.70
List Price:  L2,571.46
You save:  L734.75
ден5,897.23
List Price:  ден8,256.37
You save:  ден2,359.13
MOP$797.27
List Price:  MOP$1,116.21
You save:  MOP$318.94
N$1,833.49
List Price:  N$2,566.96
You save:  N$733.47
C$3,664.75
List Price:  C$5,130.79
You save:  C$1,466.04
रु13,546.73
List Price:  रु18,965.97
You save:  रु5,419.23
S/370.84
List Price:  S/519.19
You save:  S/148.35
K403.85
List Price:  K565.40
You save:  K161.55
SAR375.59
List Price:  SAR525.84
You save:  SAR150.25
ZK2,756.13
List Price:  ZK3,858.69
You save:  ZK1,102.56
L477.10
List Price:  L667.96
You save:  L190.86
Kč2,408.98
List Price:  Kč3,372.68
You save:  Kč963.69
Ft39,690.03
List Price:  Ft55,567.63
You save:  Ft15,877.60
SEK kr1,103.14
List Price:  SEK kr1,544.45
You save:  SEK kr441.30
ARS$101,779.64
List Price:  ARS$142,495.57
You save:  ARS$40,715.92
Bs688.19
List Price:  Bs963.50
You save:  Bs275.30
COP$435,927.07
List Price:  COP$610,315.34
You save:  COP$174,388.27
₡50,246.58
List Price:  ₡70,347.23
You save:  ₡20,100.64
L2,528.04
List Price:  L3,539.36
You save:  L1,011.31
₲776,552.46
List Price:  ₲1,087,204.52
You save:  ₲310,652.05
$U4,441.97
List Price:  $U6,218.94
You save:  $U1,776.96
zł408.81
List Price:  zł572.35
You save:  zł163.54
Already have an account? Log In

Transcript

Chapter Eight selectors. In this chapter, we'll be giving an introduction of what selectors are. We will be discussing different ways to stabilize a selector. We'll go through the differences between full versus partial selectors. And we'll also talk about wildcards and indexes in selectors. Introduction.

A selector is an XML string, which contains some attributes that help the UiPath workflow to identify the UI elements that need to interact with the target application. A selector may have as less as two attributes, or could have as many as hundred attributes. So just to give a quick overview of how a selector looks like, you can check this out. Right for a notepad document. This is how a selector looks like. Right to understand what selectors are the most must first discuss what is the structure of external applications.

So, an external application may have user interface elements like text fields, checkboxes, menus, etc, each having their own purpose and capabilities. These UI elements are built using containers one inside the other. Inside containers we have variety of UI elements with specific attributes describing their properties, capabilities, and associated traits. The selectors include a combined range of all this information to be able to identify the UI element with maximum efficiency. elements may contain other sub elements with their selectors. to direct our actions to the specific UI element, we must cautiously select the selector to the most granular level pointing to it.

You can also draw an analogy of structure of UI elements with web design. concepts using HTML and CSS. Right? selectors are generated and optimized automatically for all interactive activities. That is, wherever it is needed to interact with an external application selectors would be associated. However, they need to be debugged.

And quite often, if they don't work as expected upon re execution of the workflow. They need to be changed. To understand selectors better, let's go to UI explorer in our UiPath studio, which is right here. So in here, the leftmost pane, right describes the visual tree which represents the hierarchy of UI elements as mentioned while discussing the element structure. Right. You can see that for let's say, for this notepad document, we have this edit and we have menu bar title.

Are many of our application a table text and scroll bar, all these different elements that are there, right? So, you have like in the title bar you have minimize maximize, if you want to see what the properties of maximize are, this is how it is. Right. So, this selector editor pane, which is this one provides the attributes that are chosen to create a valid selector. The selector editor panel, which is on the right lists, easy to read selector attributes to make them comprehensible to users. Right, you can make an educated guess that you know, this is the name that is given to this button and this is the row, it's gonna be like a push button is the activity that's it's gonna, you know, that will be operated on it and so on.

Right, that's the text that is given. So, the bottom pane with all the XML tags concatenated are called the final selectors. These are modified instantly when an attribute from the selector and it like window is checked or unchecked, such as window, right click additional information. To view the selector of any UI element, you can click the mouse pointer, which is here on the top left corner of the UiPath explorer window and select the UI element. Right? So because all right, so that's how it is like, you know, highlighting and showing what.

Let me find that again. This is the editable text, right? So you can see it automatically gets highlighted, and you can press Escape to get out of it and stuff. Right. So, corresponding selector, you know, with the structural hierarchy would be shown and additionally to highlight the UI element on screen Simply choose a selector. And we can also highlight it.

So if you want to have the UiPath and put the windows right away, you can just click this button, which is the highlight button, and a yellow box appears. And you can also see are the element, the corresponding UI element is highlighted. Right? Just these are like a few tricks that people use to, you know, get to know which element we'll be working on. And just to confirm that, you know, whether the UiPath studio is able to correctly identify the element or not, right. And in case UiPath, is unable to identify the UI element, you can click UI frameworks option from the UI explorer and select the relevant setting.

Like usually it goes with the default but there could be like a change of settings like if this is for UI automation of recent activity visibility, then you can choose that but usually I've never seen working this, the because by default, it always works. Right, you have to you might have to play around with the selectors, which we'll be touching up in a few minutes. So as application interfaces become complex, the hierarchies for the associated UI elements go several layers down. Right. And the selector defines the true path of the UI element based on the containers, other route elements and associated properties, no matter how convoluted they exist in an application. And in final selectors, the first part of the XML tag describes the UI element, the type of the UI element, like, you know, if it is a window, right, then it has it will always have a tag.

That's going to start with this Wi Fi app, right? That means a window application. Other types could be like HTML elements, controls, Java, etc, etc. attributes or properties of the UI element, succeed the type of UI element in selectors and attributes include properties such as application name, title, as you can see right here Class IDs among others, right. So, you have seen how, in our basic recording chapter as well, how we created the selectors, whenever we are in any activity, whenever we are interacting with any target application, then we have to choose a selector or we have to choose the UI element and correspondingly the selector is generated. And going to the UI Explorer, you can highlight you can check whether the correct element is identified.

Even on re execution, you can check whether there was some issue or you know, if UiPath is not able to and if somehow you're not able to comprehend with the error note upon execution of a workflow that, you know, there was some issue with the selector you can always check and debug and make corresponding changes to the selector right. Okay. Next is stabilizing a selector working with activities UiPath explorer provides a complete view of all UI elements present on a screen along with their selectors. Since this is a wholesome place, it is of great benefit to a developer that we don't have to deal with all selectors every time, an activity interacting with external application is used. For this, we have access to selectors presented the Properties panel. I showed that to you in a few, like minutes back, let me show it to you again.

So let's say we have this activity. And here instead of going to the UAV, Explorer, we can get the selector from here, right. The selector editor window, shown in the Properties panel of an activity is simply an uncomplicated view of UI Explorer. There are only two panels within this window, attributes and final selector. The attributes listed here are simply a subset of the complete hierarchy visible to UiPath Explorer. This is a crisper view and makes it Easier to modify the attributes generate the corresponding selector and identify the UI element to perform intended action.

Checking and unchecking these attributes are these. Yeah, these attributes will make corresponding changes to the final selector. It is also worth noting that each attributes shown in here doesn't necessarily correlate to one element of the final selector. In other words, many attributes make clubbed together to make changes to one XML tag. And vice versa is also possible. Right.

Okay. Next, opening UI Explorer, as the name suggests, to view the full list of selectors along with the structure hierarchy, we can click this link. I just clicked on it and here it is. Right UiPath in turn will be redirected to UI UX. For the selected from the activity chosen for per user, if needed, we may have to attach the UI element again, to enable UI paths to provide the selector. Right, that's because in case we are re executing, we might not be able to find the corresponding selector on the screen or the corresponding UI element on the screen.

So that way, we might have to attach it to the live element again, and then we will be able to open it in the UI explorer as well, because for the for the UiPath. Studio, that element doesn't exist at all. So you might have to, you know, identify or make it identifiable for the UiPath to open it in the UI Explorer. If the element doesn't exist, it's not gonna be shown in here, right. Which brings us to the third component of select operator called attach to life element. One of the best features that helps choosing the best selector to be able to identify the correct UI element during multiple executions is provided in this link.

Consider that you need to click a button in an enterprise application and upon re execution workflow errored out stating that the UI element couldn't be identified. In such cases, we can try attaching the selector to that activity with the live UI element currently visible on screen. This in turn will make the selector from current element you know, using the wildcards or D selecting the variable attributes, which could also be the case. Right. And will make it identifiable, the chance that the UI element will be identified correctly upon execution of workflow increases tremendously by this capability with bare minimum effort of manually playing around with the selectors, right, just to highlight how this works. Let's say we have this untitled document notepad document where, you know, in this it's looking at the format by And then clicking on this, right.

So now if I take another notepad document, right. And that's because if you see, it's only working for those notepad documents which have, which are untitled, right? So this is gonna work. But if I say, save it with some name, let's say, ABC, right, and attach it to the live element. And in here is the live element. He says the selector was updated to match the live element, and instead of untitled, now, it says start.

So that means for any notepad documents with any name whatsoever, but it needs to have any name, hyphen, Notepad, that should be the name on the title window, and then it's going to work for those. It's going to click on that. format, but enough any of those no notepad windows, right? So that's how you attach to a live element. So that if there are any minor changes in any of the attributes that are there in the selector, then it automatically gets updated. And it the UI element becomes identifiable for the UiPath studio.

Okay. So I highly recommend that you know, you use this attached live element and play around with it. Next, we're going to talk about full versus partial selectors, right, full selectors. Full selectors refers to the inclusion of all the elements needed to identify a UI element, including the root level container. We also mentioned this in the recording chapter, right? That basic recording supports full selectors.

And to showcase how it looks like I have actually chosen this as from the basic recording itself. And you can see there is a window application, notepad Dotty xe and all the you know, for the format but just for the Format button, you see we have like the whole container shown in here. But say if I take the desktop recording, and I take this, I don't want any anchor and cancel this I should do and if you see in this, this is the same format button, but this time it doesn't have the notepad daddy xe and all the the container which was at the top posts are the root most level because we haven't attached window element which is acting as a container and sort of redirects or first it's going to find that window which is going to have untitled notepad and as per this workflow, and IT drills down to the granular level, and makes our interactions with the UI elements more sophisticated, more better, more optimal, right?

So this is like a partial selector. And the one in the basic recording which we showed just now was full selector. So partial selectors include only those elements associated directly with the UI element. They do not include root level windows or containers and their attributes. And this is because they're generally included in the containers separately, right? And uncompelled, the full and partial selectors it can be observed that the first XML tag describing the Windows application attributes is not available in purchase electro Other than that, they have precisely the same you know, capability and they accomplish the same task.

Okay. This brings us to the next topic, which is wildcards. So, there are various ways in which are selected As customized, this is important to build reliable bots. As we can't rely on a process that works say only 80% of times, there may be some changes in overall look and feel, or interfaces of an application. And selectors should be chosen in a way that they should still be able to manage in identifying the current correct UI element, since their internal attributes remain the same. For instance, say you need to input a file generated by an enterprise system automatically every day.

The file name includes a timestamp, which means a different name would exist upon every execution on a daily basis, right of the program. In choosing the selector, we may have the title of the generated document as part of the selected attribute, which upon re execution will fail, as the workflow won't recognize any elements from it. Right because of the timestamp, it's going to be different date and different probably different Time, but at least it's gonna be a different date for sure every day because the task is working on a daily basis, so the selector won't be able to identify. Of course, if it is a full sector affair is taking the title of the window into consideration the title of the file, right in such cases, the best strategy is to use a dynamic selector that possesses of varying value and can accommodate changes to recognize the correct file upon each execution.

Wildcards provide such capability. wildcards in any generic programming language represent an unknown type. This helps in analyzing the pattern of UI elements and AIDS in recognizing it more efficiently. There are two major wildcard characters used in UiPath. So first is the star. Right?

And star can replace any number of characters including no characters, while the question mark replaces exactly one character and the character needs to be there. The no character possibility doesn't exist for question marks. So, you can say wildcards can replace parts of an attribute within selector that changes over time. And the user may not know of it until runtime. Let's continue with the instance where the file was generated right and we just used it in here, where if we have to make this you know, workable for all the notepad documents for any of the titles, we can simply make, you know, like in here in the title, you can simply make it as star and that way are, you see correspondingly the added attributes. For this particular this particular attribute of the selector automatically got changed, and now all the titles are going to work.

So either you can do this or adapt to live element. Either ways, they're gonna work They play a huge role, trust me, because you will be going through a lot of different files. And you don't want to input each and every file, it's never a good idea to use static values for a selector or even for your variables. When you be dealing with large, complex automations. You want to keep them as generic as possible, you want to make them being able to correctly identify the UI elements are correctly able to identify the files, use wildcards so that you know, you can get to, let's say, a specific directory or to a specific location and can select the file based on the input fields that are provided. Which in this case, if it is a star, then automatically all the files would be selected and that's what if you want as per your business need, that's how it should be accomplished.

Right? additional information is the genuine web automations we mostly use wildcards in selector attributes, since we have a lot of varying color intent, such as placement of search boxes, window titles, possibility of some content carried forward from the last browser window we were working on, etc, etc. legibly, we can use attach live element option to let UiPath create selectors with wildcards for us. But the concept certainly comes useful to validate and or make any ad hoc changes needed in the UI identification process. This brings us to the last topic of this lecture index attribute. As discussed in arrays under data types chapter, and index is used to identify the position of an element.

In case of selectors. It defines the number of element it needs to pick from a container. In many cases, the index element comes firsthand from the UiPath itself, which tells us that there aren't enough attributes UiPath could find for precise identification of that element and in such cases, they are Line activity depending upon the positioning of an element to identify it, it becomes a little unreliable and should be avoided if possible, right. Let's see a quick example of index attribute. Suppose in UiPath, right we have a notepad document open with its font window. And we want to use a click activity, which is gonna click on the 10th lowest element, which is there in these size.

So in this case, 234567, which is 22 in here, right? So let's open the click element and we chose 22. Right and if we go and see it selector, that's how it looks like with all the attributes Right, then window application is notepad and Ctrl, ID and control name and the number that it needs to take. Right? Let's say we take out this 22. Right?

So now if we go and see if the click operation will take place on 22 or not, you can pretty much Imagine if it will, or it will, it will not, I just ran it and didn't click on the 22 element. Right? It's still like that. So, what you first and foremost, the first approach you should do is you should attach it to the live element. And this is where 22 is, and I took out 22. So now, if you see I have an index attribute instead of the name instead of the 22 number, because I took that out.

So it took the index attribute, which means the 10th element of this particular list is being chosen. And it's not a reliable one. But there are cases that you might have to use index attribute right So, you know, if we go and defeat this has been attached to the live element, it has been validated. I mean, we can validate it if we want to. But if you want to check whether it's gonna click on the number 22 or not, let's run this program. And you see, the click operation did happen to give another quick, you know, demo, if let's say we want to click on the fifth element, whichever is the fifth element in that particular container of the size, right within the notepad window, then we just change the index to five, and we run this ever click on the fifth element, which is 12.

Right? So index attribute is also a way to locate UI element based on its position. And it's like, you know, indexes in the selectors. They come with very precise requirements, and users must be very, very careful. while implementing them, if you know that your business requirement that you're trying to implement has a, you know, very concrete requirement that it needs to select the 10th element no matter what the list is or what the container holds, or what different application will be working on what different environment is going to be, if that's going to solve the purpose, definitely cool with the index attribute. Or if there are not enough selectors for UiPath or for you to comprehend and find out the most granular level detail of the UI element, then definitely, it's a it's a decent approach to go with.

Okay.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.