I have a situation in protractor where I want to store ElementArrayFinder getTexts in Array and return array from method. I have written the method so far like this:
static getAllTexts(elements: ElementArrayFinder) {
const data: string[] = [];
elements.each(function(elem) {
elem.getText().then(function (text) {
data.push(text);
});
});
return data;
}
Here the method is returning blank array but if I print array content inside promise, it is showing the correct data. Can anyone please help me to rewrite the method so it returns all the array data instead of returning null.