1. Introduction #
When using Locator and Web Automation, it is crucial to have a good grasp of the various attributes that Clicknium employs to locate web elements. These attributes include “tag,” “id,” “name,” and others.
Sometimes, web elements may have additional attributes that are equally important and can be utilized to identify the web page. Therefore, if the locator validation fails after running the script, it is helpful to modify some of these significant attributes to replace the first locator attribute that was captured. This is a common scenario that we can go through together, and I can provide an example to help you better understand it.
2. Version Requirement #
To take advantage of this functionality, you’ll need to have the following installed:
- Clicknium Visual Studio Code Extension 0.1.9 or higher
- Clicknium Python Module 0.1.8 or higher
Note: For more about the installation and the tutorial of Clicknium Automation, please refer to here.
3. Samples #
The example below demonstrates how to take advantage of this functionality.
Sample 1: Azure DevOps new work item page
It is simple to generate the locator like the one below using Clicknium Recorder , however in this scenario, the “ancestorId” of the produced locator is dynamic; if you create a work item again, the “ancestorId” will be change.
Given that Clicknium returns the values for all of the web element’s attributes, choosing “aria-label” and excluding “ancestorId” will make the locator more dependable for this sample.
In order to be flexible, we should alter the “title” to “New Bug *: – Boards”. Please refer to wildcard locator and Recapture and Compare.