I'm running protractor testing in angularjs application.
let index;
let elm = element.all(by.repeater('registration in myRegistrations'));
elm.getText().then(function(text){
console.log(text);
for(var i=0; i<text.length; i++){
if(text[i] == 'protractor-testing'){
index = i;
console.log('Test found :: ' + text[i]); // get the correct value
}
}
});
console.log("Index :: " + index); // It says undefined
Here, I get the index result inside if of the for loop function but When I print the index in the console in the last line it says undefined.
How can I get the value of index ?