In an html page I have:
<ul class="phones">
<li ng-repeat="phone in phones | filter:query | orderBy: orderProp">
{{phone.name}} - {{phone.age}}
<p>{{phone.snippet}}</p>
</li>
</ul>
In an e2e test I have (is returning two elements in the array):
var result= ptor.findElements(protractor.By.repeater('phone in phones').column('phone.name'));
result.then(function(arr) {
arr[0].getText().then(function(text) {
console.log("*** 1: "+ text);
});
arr[1].getText().then(function(text) {
console.log("*** 2: "+ text);
})
});
The console is printing all three columns, phone.name, phone.age, and phone.snippet. Why is the selector not just returning phone.name?
Its actually returning whatever I have in the list "li", plain text or a binding.
The example tries to locate elements with the strategy below (column part is fixed as per comments):
protractor.By.repeater('phone in phones').column('name')
Repeater part matches the li
element and then goes to find element(s) with phone.name
binding. It's wrapping element happens to be the same li
.
Changing column part to .column('snippet')
returns p
elements because phone.snippet
binding is found inside of those.
Relevant docs/examples here: https://github.com/angular/protractor/blob/master/docs/getting-started.md#writing-tests
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With