ACCELQ simplifies the automation development by supporting a Locator-Free approach to element identification. This eliminates the need for frequent maintenance efforts, as automation scripts are not impacted by changes to the application's front-end HTML structure.
ACCELQ Recorder intelligently defaults to the Locator-Free approach wherever a hint could be calculated. In exceptional cases, the system may utilize Smart Locators.
The Locator-free approach is very robust and effectively handles false positives, enabling confident utilization for verification and synchronization requirements in addition to the interaction-related commands.
This approach to element identification makes the automation logic more readable and intuitive and allows for faster script development during sprints.
Note: When using Locator-free Element ID, there is no need to save Views. And, as the name suggests, the Elements are not required to be managed in the repository at all.
Important Attributes of text-based identification
Two important attributes, Label and Anchor-text, play a crucial role when working with text-based commands.
Label
The Label of an element for the purpose of Locator-Free identification can be any visible text or otherwise relatable text on the element.
For example, it could be the label of an input field, the text on a button or link, placeholder text, etc. Sometimes, the label may be displayed as clear, visible text conventionally associated with a field (such as an input or dropdown) on the screen, or it may be self-text for a link or button or a placeholder for an input field.
Additionally, the label could be a hidden textual property as well. In the ACCELQ Recorder, if you hover over a particular element (and wait for a few seconds), you will see this hidden attribute displayed against the Locator-Free label on the tooltip.
Anchor text
Anchor text is any visible text that is closer to the element on the upper or left side and can be used to resolve the uniqueness requirements of the Label property. If the same label exists in multiple places on the screen, you can use Anchor text to point to a specific instance of a matching element.
If specified, the search for Label is limited to the area under/right of the Anchor text.
The example below can use "Ship to different address" as the Anchor text for the "First name" we are interested in.
Operators for Label and Anchor Text
Both the Label value and Anchor text value can be specified not just as an exact matching text, but with a wide array of other operators. These are useful when the text in the Label or Anchor text is somewhat dynamic and variable. Here is the list of supported operators:
- equals
- equals, ignore case
- contains
- contains, ignore case
- starts with
- starts with, ignore case
- ends with
- ends with, ignore case
- matching regex
Index
When there are multiple instances of the same Label, you can target a particular one using the "index" feature, which identifies an element based on its sequential order.
When used in conjunction with the Anchor text, the process first identifies all matching elements that fall below the Anchor text. Then, it applies the specified index exclusively to those elements.
The index is denoted by appending "#n" to the Label. For instance, "First Name#2" targets the second occurrence of "First Name" either on the screen or in the context of the specified Anchor text.
Examples of text-based automation approach
Here are some examples illustrating the vast applicability of this feature.
Enter text in an input field based on its label
In the example below, you could enter a value in the Username field using the label for the input field.
Enter text based on placeholder text
In the example below, you could enter a value in the Username field using the placeholder for the input field.
Select an item from a search dropdown
Text commands for searchable dropdowns support extensive capability to search for an item and select one of the resulting options. Selections based on the index are also supported in addition to pattern matching of options.
The following statement searches for "COB" text in the searchable dropdown and selects the second option from the resulting list. Note that the index starts with 1.
Clicking on an element based on the tooltip
In the image below, you will notice the edit icon has a tooltip "Edit Account Name". You can use the tooltip exactly the way that you would use visible text on the screen.
Clicking on a radio button option
The radio button option in the image below can be selected simply by providing the option name as clickable text.
Clicking on a link whose text is dynamic, but present under a known label
The Account Name link in the image below needs to be clicked as part of the automation logic. However, the text associated with the link is dynamic. To handle this scenario, you can create a click statement using a regular expression of ".*" (which matches any text) for the label, and specify an anchor text of "Account Name". This way, the automation logic can successfully click on the link, without relying on the actual account name.
Using dropdown commands for non-standard controls that allow selecting options with a click
Dropdown commands in ACCELQ can be used for any control that opens a list of options upon clicking, not just for conventional HTML dropdowns. As seen in the image below, the "Search Parameter" button opens a list of options that can be interacted with using the text-based dropdown commands.
Dealing with repeat elements
In the example below, the "Add to Cart" button is repeated multiple times for different product offerings. To accurately interact with the desired button, you can use the Anchor text to differentiate between instances of the repeating button and click the one you need.
Note: When recording or playing back a statement in the Design Studio, the system will warn you if it finds multiple labels that the statement is referring to. You can find this warning in the Design Studio console, and during playback, the element will blink in red in the Recorder browser.
You can review the warning and update the command with the appropriate anchor text to locate the desired instance of the element uniquely.
Click a Repeat Element where the Anchor text is a variable
In the screenshot below, the Anchor text is variable but has a specific pattern (starts with). We can use the appropriate operator for the Anchor text to click the correct "Add to Cart" button here.
Clicking a repeat element based on the tooltip, and anchor text
In the screenshot below, you can click on the "Settings" icon for the "Internet" package by using a combination of the tooltip (as Label) and the Anchor text.
Note on conventional Element ID (Smart-Locators)
Whenever possible, it is better to use the Locator-Free approach for element identification, as it simplifies both test development and maintenance. However, there may be situations where the conventional DOM-based element ID (Smart-Locators) may be preferred due to the complexity of the logic involved. Here are some exceptional situations where Smart-Locator may be handy:
- ACCELQ may fail to calculate Locator-free hint for certain elements. System defaults to Smart-Locators in this case.
- For some Elements, Locator-free may become too complicated to address, even when using operators like starts-with, ends-with, contains, regex, etc. In such situations, it is best to utilize Smart Locator instead.
- Advanced concepts like Container Elements and Repeat Elements are best handled with Smart Locators.
- It's important to note that Locator-Free approach does not support the concept of Element Instances (multiple Element ID variations for the same Element to account for resolution/OS differences).
Comments
0 comments
Please sign in to leave a comment.