To make use of UIAutomation and WebAutomation actions, use of AppMasks is required. AppMasks, contains the selectors of the elements of Web and Desktop Applications used.
An AppMask file has the extension “.appmask” and can be generated using the UISpy Application.
An AppMask file is in the form of a tree structure in JSON which contains an Application. The application then contains multiple screens. Likewise, every screen contains multiple controls.
Both Screens and Controls use selectors to locate elements on the applications.
To add a screen to the AppMask, click on the “Add screen” button and the “Tracking Session Window” will appear. Hovering over windows of the machine, a red rectangle will appear allowing you to select the window of your preference. Hold down the Control Key and click on the Window to select it. Once the Window is selected, it will appear under the UI Spy Editor.
Similarly, Controls can be added to an AppMask by clicking the “Add Control” button. Hovering the mouse over elements on the screen will show the red rectangles around them. By holding the Control key and clicking on an element, the respective control will be added on the “Tracking Session Window”.
Once you click on “DONE”, all the Controls will be sorted under the respective Screen of the Robin UISpy Editor.
To import an AppMask file to an automation the term import needs to be used followed by the path to the file in quotes.
The AppMaskFile located under the “C:” drive is imported to the automation.
The import statement should always be at the top.
Once a file is imported, the controls can be refered using the elements of the tree structure. In the following example, the calculator application is used.
The application is called CalcMaskApp and the application set is Calculator. The Screens captured are named Window_Main and Second_Window. Button_1, Button_2 and Button_3 belong to the Window_Main Screen, while Button_4 is Second_Window’s control.
To call a control of the AppMask in an action the name of the AppMask, the Screen and Control are required. However, the Application is not mandatory.
In AppMasks containing only one Screen, the Screen value can be omitted as well.
As a result the syntax of the control of Button_2 and Button_4 would look as follows.
Below the control of Button_3 is used within the UIAutomation, “Click Element” action.
UIAutomation.Click Element:CalcMaskApp.Calculator.Window_Main.Button_3 ClickType:ClickType.LeftClick MousePositionRelativeToElement:RectangleEdgePoint.MiddleCenter OffsetX:0 OffsetY:0