Identify controls by anchors
If you want to make your test automation more reliable and adaptable to UI changes, you can uniquely identify your controls by anchors.
Anchors are controls that work as positional reference, providing context or information about the location of the control you want to identify.
For example, if you copy the text displayed in a Label close to a Textbox to transfer it into the Textbox itself, Tosca first searches for the anchor control (the Label) and then uses its identification criteria as a reference to find, interact with, and identify the selected control (the Textbox).
Textbox with Label example
Identify by anchor
To identify a control by anchor, follow these steps:
-
Scan your system under test with Tosca XScan.
-
In the Advanced View, select the control you want to identify.
-
In the ribbon menu, click Identify by > Anchor.
Optionally, configure the Relative Algorithm.
-
Select the control you want to use as positional reference . This control becomes the anchor of the control you want to identify.
Keep in mind that Tosca automatically searches for possible anchors and picks a unique anchor control. When it can't automatically assign an anchor control, you need to manually select an anchor through one of the described methods in the Identify by Anchor window:
-
If you use a mouse, drag and drop one or more controls from the list onto the Anchor Control panel.
Alternatively, click the Select on Screen button, then directly select anchor controls in your system under test, and confirm your selection when you're done by clicking Select on Screen again.
-
If only use a keyboard, use the Select from Tree View button to select your anchor controls and press Enter.
When you successfully identify a control, the Anchor Control Properties panel shows the anchor's technical properties that Tosca uses to identify the selected control.
-
Remove anchors
To remove an anchor, right-click the anchor control in the Anchor Control panel and select Remove Anchor.
Relative algorithm
Use the Relative Algorithm to specify the preferred search method:
Value |
Description |
---|---|
ShortestPath |
Tosca starts searching for the control starting from the children controls of the anchor, then it extends the search on every tree level until it reaches the root element. |
Coordinate |
Tosca uses the coordinates of the anchor control to locate a search angle and find the control. |
Auto (default) |
Uses the ShortestPath algorithm by default. If the ShortestPath algorithm was unsuccessful, the system automatically switches to the Coordinate algorithm. |