I'm new to AngularJS/protractor so any guidance on this is much appreciated. Since Angular JS instantiates html elements via ng- directives there are no 'id's etc that allow me to locate specific elements. (Obviously I want to do this to validate content, click them etc.) My angular js snippet looks like:
<div ng-repeat="item in myList">
<span ng-if="item.category == 'lights'">
<img src="../../../{{item.icon}}"/>
 <span id="foo">{{item.name}}</span> 
</span>
</div>
I'm trying to locate the elements {{item.name}} as I iterate over the list with this:
element.all(by.repeater('item in myList')).then(function(rows) {
noOfItems = rows.length;
for (i = 0; i < noOfItems; i++) {
row = element.all(by.repeater('item in myList')).get(i);
row.isElementPresent(By.id('foo')).then(function (isP) {
if (isP) {
console.log("foo exists?" + isP);
row.findElement(By.id('foo')).then(function (el) {
el.getText(txt).then(function (txt) {
console.log("Item name " + txt);
});
});
}
});
}
});
From inspection the 'row' element seems to be selenium object so I invoke 'isElementPresent(...) and this works great. It detects the correct number of 'foo' elements. However when row.findElement(...) runs, the test spec terminates prematurely. (No errors, it just ends)
I know that there will be multiple 'foo' elements in the document however I was hoping that since they are being queried within a sub html element, (row) this might work.
Any suggestions/workarounds?