UI automation refers to the automation of desktop applications and web browsers. It can replicate clicking and typing in various user interface elements such as buttons, check boxes, text boxes, or drop-down lists. Knowing how to interact with them enables you to design automations much faster and easier. With StudioX, you can create automations with UI elements from most applications using application or web activities.
Note:
StudioX offers deep integration with Microsoft Office, Outlook 365, Gmail, and the file system. Use the dedicated activities when automating Excel, Mail, Word, PowerPoint and file and folder operations.
All interactions with the UI can be split into input (sending or adding something to the application) and output (getting something from the application). Clicking a button and typing text in a text box are examples of input actions. Getting the text from a browser page is an example of an output action.
StudioX comes with activities that help you automate most common UI interactions. The first step in automating UI interactions is to define the desktop application or web page to interact with by adding a Use Application/Browser activity. You then add the activities to automate in that application or web page inside the Use Application/Browser activity.
To speed up the process, you can use the App/Web Recorder that automatically generates activities by capturing your actions on the screen.
To learn how to work with UI automation, see the tutorials in this section.
To find out more about application / web activities, this section contains detailed descriptions for each activity.
About Targets and Anchors
A target is a UI element you want to interact with, for example a button to click, a text box to type into, or a part of a web page from which to copy text.
An anchor is another nearby element that helps to uniquely identify the target. When you indicate a target, UiPath tries to identify and automatically select an anchor. You can also manually add up to three anchors.
After a target is selected, you can edit selectors on the spot from the Selector Options window, under the Window selector section. It's also possible to open UIExplorer from here for advanced selector editing.
When to Use an Anchor
Anchors are useful when a target element is not unique. For example, a form in a desktop application typically contains multiple similar text boxes into which to enter various data. The way you identify what data needs to go into each one is by looking at the labels next to them. Similarly, when the label of a text box is added as its anchor, the Robot uses the anchor to identify the text box to type into.
In some scenarios, multiple anchors are required to distinguish a target from other similar elements called duplicates. For example, if a form contains billing address and shipping address sections, the text boxes in them appear twice with the same label, so you need to add both the labels (e.g. "Zip code") and the title of the section (e.g. "Billing address") as anchors to identify the correct one.
Indicating a Target
In most cases, all you have to do to define a target is point to it on your screen and click. The methods required to identify the target and any suitable anchor are detected and their properties are automatically generated.
To indicate a target:
- Click Indicate target on screen inside an application/web activity.
The target selection mode is opened. As you start moving the mouse, all the recognized UI elements are highlighted. The Selection Options window appears on the screen with information about the target identification status and additional options. - Place the mouse pointer on the desired element, make sure it is highlighted, and then click it.
- If the target element is identified, it is highlighted in green.
- If an anchor was also automatically selected, it is highlighted in blue.
- If an anchor was not automatically selected, you can click a nearby element that helps identify the target (for example, a label or a title) to add it as an anchor.
- To add an additional anchor, hover the target element, select Add Anchor in the hover menu, and then click the element to add as anchor.
- If the target was not identified because there are too many other similar elements on the screen, the element is highlighted in red and the similar elements are highlighted as duplicates in yellow. Click another element on the screen to add it as an anchor.
- If the selection is valid, the target and anchor are highlighted in green and blue respectively.
- If the target and anchor are highlighted in red, the selection is still invalid. Hover the element you indicated as target and click Add Anchor in the hover menu to add a second anchor. Repeat this to add a third anchor if necessary.
- If the target element is identified, it is highlighted in green.
- To complete the target identification, click Confirm in the Selection Options window. You can also confirm by clicking in the target hover menu or by pressing Enter on your keyboard.
The target is configured and the activity displays a screenshot of the target and any anchors that were added.
Additional options are available in the Selection Options window to help you indicate elements:
- If an element is not visible on your screen or the application is not in the correct state, you can press F2 on your keyboard to pause element selection while you set the application to the correct state.
This is useful for elements that require an additional action to appear on screen, or disappear easily from it. For example, if you want to indicate specific elements in drop-down or hover menus, you can pause selection while you click the drop-down or move the mouse pointer on the hover menu to activate them. - Switch to Image selection mode. Press F3 on your keyboard to change to image-based identification only, and then use your mouse to select a visible region from the application window to use as target or anchor.
- Change the UI Framework. By default, a proprietary framework is used to access the target application window. If a target is not detected, try to change the framework by pressing F4 on your keyboard. Select AA (Active Accessibility) for older applications or UIA (Microsoft UI Automation) for newer applications. After you select a target, the option to change the UI Framework is no longer available.
Editing a Target
If the target is not identified correctly during project execution, you can edit the target and its anchors after you have indicated it by selecting > Edit Target in the body of the activity. This opens the selection mode with the target and any identified anchors highlighted. A menu is displayed when you hover the mouse over a target or anchor.
- To remove a target or an anchor, hover it, and then click Delete in the hover menu. If you remove a target, the first element you click is added as the new target.
- To add an anchor for a target, click the element to add as an anchor. Depending on the settings of your project, you may need to click Add Anchor in the hover menu of the target first. You can add up to three anchors for each target.
- To edit a target or an anchor, hover it, and then click Settings in the hover menu. The properties of the methods used for detecting the element can be edited from the Advanced Settings section of the Selection Options window:
- Selector / Fuzzy Selector
- Edit the selector using the corresponding text box. To copy the selector for pasting in another element or for editing in the UI Explorer, click Copy next to it.
You can use variables in attribute values. The variables must be surrounded in double curly brackets, for example<wnd name='da{{var1}}'/>
adds the value ofvar1
to the selector. The default value of the variable is used at design time. For information on how to create variables for selectors, see Creating Variables for Use in Selectors. - For Fuzzy Selectors, you can change the Selector Accuracy level by dragging the corresponding slider from 0.4 to 1. This measurement expresses the level of similarity between the attribute you are searching for and the one to be found. To find results with a higher similarity, increase the value. The default value is 0.7.
You can find more information about selectors in the Studio guide.
- Edit the selector using the corresponding text box. To copy the selector for pasting in another element or for editing in the UI Explorer, click Copy next to it.
- Image
- Change the Image Accuracy level by dragging the corresponding slider from 0.4 to 1. This measurement expresses the level of similarity between the image you are searching for and the one to be found. In situations when the image to be found can be slightly different than the one you are searching for, you can lower the accuracy. The default value is 0.8.
- Disable / enable a method by clearing / selecting the check box next to the method name.
- Verify how unique a method is by clicking Show all matches next to it. This checks all the elements in the window and highlights all that have similarities with the currently selected element in yellow.
- Click Apply to save the changes, and then click Validate if you want to validate the selection. To save the selection, click Confirm.
- Selector / Fuzzy Selector
Validating Your Selection
Validation enables you to check how effective the current selection is in identifying the target by checking it using all selected methods and anchors. The result of the validation is displayed at the top of the Selection Options window. If adjustments are needed, a message is displayed with information on how to improve the selection.
The performance of each method is displayed in the Advanced Settings section of the Selection Options window using one of the following icons:
The method was the first to successfully identify the element.
The method successfully identified the element.
The method failed to identify the element because too many duplicates were found.
The method failed to identify the element.
Creating Variables for Use in Selectors
You can create variables from the Use Application/Browser activity and most other container activities. The scope of the variable is within the activity where it is created.
To create a variable for use in a selector:
- In the title bar of a container activity, select Settings > Value Mappings.
- In the Value Mappings window, click Add, and then provide the following information:
- Name - Enter a name for the variable. The name should follow naming conventions.
- Value - Click Plus on the right side of the field, and then use one of the options in the menu to indicate the value to use at runtime. For example, you can enter text, select a cell from an Excel file, or select a previously saved for later text value. The variable type is string.
After a variable is created, you can add it to selectors in activities added inside the container where it was created. For more information, see Editing a Target. The variable can also be selected from the Plus menu of compatible activity fields inside the container.
For an example of how to use variables in selectors, watch the following video.
Updated 2 years ago