0
<div ng-repeat="obj in list"> </div> 

This obj is having 6 properties like name, country, state, city, street, and contact. I have written following code for this but it is giving me undefined as the value if i try to fetch the stored value in obj.

var elm = element.all(by.repeater('obj in list')); elm.then(function(obj){ console.log("Number of Rows : "+ rows.length); for(var i=0; i< rows.length; i++){ console.log("App name : " + rows[i].name); } }); 

This is printing "App name : undefined" only.

2 Answers 2

2

Keep in mind that you are using promises so you can't log a unresolved promise. All executions in Protractor are promises. Secondly, you are using the rows, but you never defined it. Is rows the same as obj?

Third, try to avoid the a for loop with Promises. It's better to use for example the each from protractor. If you do that your code looks like this

var elm = element.all(by.repeater('obj in list')); elm.each(function(obj, index) { // Will print 0 First, 1 Second, 2 Third. obj.getText().then(function (text) { console.log(index, text); }); }); 
Sign up to request clarification or add additional context in comments.

Comments

1

firstly, the ng-repeat does not contain an object, it contains a list. in your case, an array. if you have nested lists (ng-repeat in ng-repeat) please specify that in your question. otherwise, the following code should work for you.

let elm = element.all(by.repeater('obj in list')); elm.getText().then(function(text){ console.log(text); }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.