Lesson 6 selectors
we can learn about the beautiful feature selected using lesson 6 selectors. The selector is a string of characters (VB expression),it has been used to identify objects on the screen. The selector is one of the properties of UI activities and has an XML format. All the activities in UiPath Studio related to graphical elements have the selector property.
The way to identify an element on the UI tools require some kind of identification mechanism. This can be through background by element Id’s or UI Image. The unique way of identifying an element can be through its ID. User interfaces and HTML web pages are built using a series of containers, nested one inside the other. Selectors store these attributes, in the shape of an XML fragment so that a specific element from a window or page can be identified.
Below are the Key points for selectors.
- Selectors should be constructed in such a way that they point to only one element in the environment. If a robot finds multiple possible matches for a selector, it uses the first one it encounters – usually the topmost one.
- A partial selector is very similar to a full selector, the only difference being that it has
its top level window extracted into a container like AttachWindow or OpenApplication.
- Basic recording generates full selectors while Desktop recording generates only
- You can build dynamic selectors using the 2 available wildcards: question
mark (?) takes the place of a single character and asterisk (*) that replaces
any number of characters
- Use Attach to live element to update an existing selector to also match a 2nd element.
- Use the selector’s idx property to get a certain occurrence of an element that is found
- Avoid using the idx attribute if its value is larger than 2, unless you don’t have other
options. Always try to add other attributes make sure the selector is stable
- When it’s likely that you will have interference from other applications and
windows it’s best to use partial selectors.
Lesson 6 Selectors Introduction Quiz answers
1). Can UiExplorer be used to record UI interactions?
Ans : – No
2). Which of the following is a valid full selector?
Ans: – <html app=’chrome.exe’ title=’Yahoo Finance’ />
<webctrl idx=’1′ parentid=’data-util-col’ tag=’TABLE’ />
<webctrl isleaf=’1′ tableRow=’3′ tag=’TD’ />
3).What is UiExplorer used for?
Ans :- To create and fine tune selectors
To explore the UI tree
4).Which of the following statements are true regarding the Find Element activity?
Ans : – It throws an exception if it doesn’t find the element on screen
It returns the found element in a variable for later use
5). How can you improve a selector?
Ans : – By replacing dynamic attribute values parts with the “*” or “?” wildcards
6).Can a valid selector identify different elements on the screen at the same time?
Ans : – No
7). Can full selectors be used inside a container (Attach Window or Open Application activities)?
Ans : – Yes
8). What is the Highlight activity useful for?
Ans : – For troubleshooting and verifying selectors
9).The Element Exists activity throws an exception if it doesn’t find the specified element on the screen.
Ans : – False
10). How can you see the full list of attributes of Ui elements?
Ans : – By using the UiExplorer tool.
- You can think of a selector as a path to the required UI element, starting from the root container and all the way to our target.
- A selector contains 2 types of information: the element type and one or more of its attributes.
- When automatically building a selector, UiPath tries to use only the first and last container but it also adds intermediate ones only needed.
For Reference : UiPath tutorials