After loading the following elements into the DOM using AJAX:
<div class="elm_class"></div>
<div class="elm_class"></div>
<div class="elm_class"></div>
I need to wait for a specific number of elements to be present in my Protractor test. Here is what I've tried so far:
function checkElements(css, i) {
var elements = element.all(by.css(css));
var EC = protractor.ExpectedConditions;
if (elements.length > i) {
return EC.presenceOf($$(".heading-description.uplevel").get(i));
} else {
return setTimeout(checkElements(css, length), 1000);
}
}
browser.driver.wait(checkElements(".elm_class", 3), 10000);
However, this approach is not working as expected and it throws an error:
maximum call stack size exceeded.
I would appreciate it if someone could provide guidance on how to incorporate a "promise" object back into the wait function.