For our project, the automation team is incorporating a custom attribute called 'lid' to elements where unique identification is challenging.
A new custom locator method has been developed to find elements using the 'lid' attribute:
by.addLocator('lid', function(value, parentElement)
{
parentElement = parentElement || document;
var nodes = parentElement.querySelectorAll('lid');
return Array.prototype.filter.call(nodes, function(node)
{
return (node.getAttribute('lid') === value);
});
});
Provided below is an extract of the HTML code:
<div class="col-sm-8 cbx">
<p class="ng-binding"><input type="radio" ng-model="theme"
lid="create-user-them-radio1" ng-value="1" ng-click="user.theme = -1" class="ng-
pristine ng-untouched ng-valid ng-not-empty" name="1194" value="1"> Use the default
for this domain</p>
<p class="litetext ng-binding">Following options override
the domain's default value</p>
<p class="ng-binding"><input type="radio" ng-model="theme"
lid="create-user-them-radio2" ng-value="2" class="ng-pristine ng-untouched ng-
valid ng-not-empty" name="1195" value="2"> Select theme for the user</p>
</div>
The intention is to utilize the 'lid' attribute for element location and hence the creation of the aforementioned method to support any attribute and value combination.
To call the method in a test file, use the following syntax:
element(by.lid("create-user-them-radio1")).click();
An error message indicating 'No element found using locator: by.lid("create-user-theme-radio1")' is currently being encountered. Assistance is required to rectify this issue.