Declaring a Page
Set Page Criteria
Page criteria are set on the properties of the root component of the targeted screen. They are used by the UI Automation connector as follows:
The UI Automation connector searches the DOM tree to find all DOM components matching the page's criteria. If a component matches, the connector doesn't search its subtree to find other instances of the page. The connector creates one instance of the page for each matching component.
That means that page criteria must be:
-
Precise enough to match the desired root component, and no other
-
Robust enough to still work should the screens change
You set recognition criteria using Desktop Studio (see Criteria Management):
-
You can use the following operators: Full, Part, Starts, Ends, like
-
You must declare at least one recognition criterion.
-
You can set multiple criteria on the same property, which are then connected by a logical OR.
Usually, you will set recognition criteria on the following properties:
|
ControlType |
Controls such as Window or Pane |
|
AutomationId |
If present and unique, this property is usually set by developers and does not change |
|
Deepness |
See Use Deepness property under Declaring an Item below |
Advanced Recognition Methods for Pages
If the targeted root component has no unique distinguishing properties, you can use one of the following advanced declaration methods:
-
The Root Item Method
For details of this method, see Root Item Method:
-
The MustExist Method
For details, see MustExist Method.
-
The MustNotExist Method
For details, seeMustNotExist Method.
-
Order of Pages
For details of this topic, see Order of Declared Pages.
Page-Based Events
A declared page automatically receives the following technical events:
|
LOAD |
The page is loaded |
|
UNLOAD |
The page is closed |
-
Check the SPY(SUBTREE) track event (see Select Page tracked Events)
-
Run your project
-
All notification events fired by the application are displayed in the Events view in the following format: SPYTREE(event)
After receipt of these messages during the execution of the PSC, it is possible to track the events you need. To do this, right-click the desired event and select Track this event. The corresponding event is added in the TrackEvents tool window of Desktop Studio.
Page Parameters
Page parameters can be set using Desktop Studio (See Declaring Pages).
The UI Automation connector provides the following specific parameters:
|
Auto Capture on polling |
Indicates (true) to regularly capture values of items declared in auto capture. |
|
Multi-instance |
Indicates (true) if the page can possess multiple instances. |
|
Subpages Type |
Indicates whether the page can possess multiple (Multiple) or single (Single) instances of subpages. |
|
Root Item |
Indicates the item on the parent page used as the root item, if any (see Root Item Method) |
|
Refresh mode |
Determines how page recognition is refreshed (see Recognition refreshment) – No: no refresh needed – Window: refresh on WINDOWOPENED event notification – Polling: refresh by polling |
Performance Optimization for Page Recognition
Detect optimization needs
To detect optimization needs in page declaration, you can use the recognition cost displayed in the page part of the Recognition tool window (see About the Recognition Mechanism).
For each page, the recognition cost expresses the number of components that must be tested in order to recognize the page. It is the sum of the number of components tested to recognize:
-
The page's root item
-
All of its MustExist items
-
All of its MustNotExist items
The recognition cost does not give a precise value of the time spent, but a high score (for example, more than 100) indicates pages that are good candidates for optimization.
Before recognizing a page, the UI Automation connector tries to recognize its preceding sibling pages. So, the actual recognition cost for a page is its own cost or the cost of its preceding sibling pages, whichever is greater (not the sum of both, thanks to cache management).
So, to optimize the recognition time of a specific page, you need to reduce the recognition cost of the page and of its preceding sibling pages.
Optimize Page Recognition
The first way to optimize page recognition consist in optimizing:
-
Recognition of its root item
-
Recognition of all of its MustExist items
-
Recognition of all its MustNotExist items
To do this, see Performance Optimization for Item Recognition.
Optimize Cache Management
Refreshing a page by means of polling can be time-consuming, because it requires the cache to be cleared and the searched subtree to be reloaded from the controlled application (see Performance Management).
To optimize cache management, it is possible to avoid refreshing subpages that are always present.
Example:
You have to control an application with a main window (1) that permanently displays a TabControl with TabItems. You have to control two TabItems (2) and (3):
You declare the following pages:
-
pMainWindow to target the main window (required)
-
pTabItem1 and pTabItem2 as subpages of pMainWindow.
The pTabItem1 and pTabItem2 targets are not window components and must be detected by polling.
With this declaration, the whole application DOM tree is regularly reloaded. You can optimize performance by modifying your declaration as follows:
-
Declare a pTabControl page to target the TabControl component.
-
Since it is always present, you avoid refreshing the pTabControl page.
This way, only the TabControl DOM subtree is regularly reloaded.
In addition, as only one TabItem can be loaded at a time, you can set the pTabControl’s ‘Subpages type’ parameter to ‘Single’). This way, when one pTabItem SubPage is recognized, the software no longer tries to recognize other subpages of pTabControl.
Pages with a single subpage instance
By default, a parent page that has multiple subpages tries to recognized all of its subpages.
When you declare a parent page to target a TabControl and subpages to target the TabItems, you know that only one subpage is present at one time.
You can then set the Subpages type parameter of the parent page to ‘Single’. This way, if one subpage is recognized, the parent page doesn’t try to recognize the others.
Pages with multiple instances
Most pages target only one screen. To optimize page recognition performance, the UI Automation connector only searches for a page's first target by default.
If you have to manage a page that has multiple targets, check its Multi-instance parameter.
For general information on declaring a page in Desktop Studio, see Declaring Pages.