title: Protractor: Store ElementArrayFinder getTexts in Array and return array from method
body: <p>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:</p>
  
  <pre><code>static getAllTexts(elements: ElementArrayFinder) {
      const data: string[] = [];
      elements.each(function(elem) {
          elem.getText().then(function (text) {
              data.push(text);
          });
      });
      return data;
  }
  </code></pre>
  
  <p>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.</p>