How to use findAllRepeaterRows method in Protractor

Best JavaScript code snippet using protractor

Run Protractor automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

repeater.js

Source: repeater.js Github

copy
1/**
2 * Find all rows of an ng-repeat.
3 *
4 * arguments[0] {Element} The scope of the search.
5 * arguments[1] {string} The text of the repeater, e.g. 'cat in cats'.
6 *
7 * @return {Array.WebElement} All rows of the repeater.
8 */
9var findAllRepeaterRows = function(using, repeater) {
10    var rows = [];
11    var prefixes = ['ng-', 'ng_', 'data-ng-', 'x-ng-', 'ng\\:'];
12    for (var p = 0; p < prefixes.length; ++p) {
13        var attr = prefixes[p] + 'repeat';
14        var repeatElems = using.querySelectorAll('[' + attr + ']');
15        attr = attr.replace(/\\/g, '');
16        for (var i = 0; i < repeatElems.length; ++i) {
17            if (repeatElems[i].getAttribute(attr).indexOf(repeater) != -1) {
18                rows.push(repeatElems[i]);
19            }
20        }
21    }
22    for (var p = 0; p < prefixes.length; ++p) {
23        var attr = prefixes[p] + 'repeat-start';
24        var repeatElems = using.querySelectorAll('[' + attr + ']');
25        attr = attr.replace(/\\/g, '');
26        for (var i = 0; i < repeatElems.length; ++i) {
27            if (repeatElems[i].getAttribute(attr).indexOf(repeater) != -1) {
28                var elem = repeatElems[i];
29                while (elem.nodeType != 8 ||
30                    !(elem.nodeValue.indexOf(repeater) != -1)) {
31                    if (elem.nodeType == 1) {
32                        rows.push(elem);
33                    }
34                    elem = elem.nextSibling;
35                }
36            }
37        }
38    }
39    return rows;
40};
41var using = arguments[0] || document;
42var repeater = arguments[1];
43return findAllRepeaterRows(using, repeater);
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Protractor on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)