This rule would warn if repetitive locators would be detected in a single file in support of the DRY principle.
👎 For example:
var MyPage = function () {
this.grids = element.all(by.css(".mygrid"));
this.firstGrid = element.all(by.css(".mygrid")).first();
}
Here, .mygrid
locator is used two times.
👍 A better version:
var MyPage = function () {
this.grids = element.all(by.css(".mygrid"));
this.firstGrid = this.grids.first();
}
Note that the rule is looking for exact duplicates of the locators - where both the by
locator type and the value are repeated.
If this rule produces too much false positives and warns about locators being repetitive when repetition is something you have intended to have, disable the rule. Though, I suggest leaving it enabled globally and having it disabled for specific files or problematic parts of code instead.