title: Why does get getElementsByClassName() return undefined, when using puppeteer?
body: <p>Right now I'm trying to get some elements using puppeteer, to get some class items(divs). I know getElementsByClassName returns a list, which you have to parse through. However for me the function just says undefined, even when I try it in the browser (Latest version of chrome). </p>
  
  <p>Heres the code (typescript btw):</p>
  
  <pre><code>private async getElementsFromBrowser(url : string) : Promise&lt;any[]&gt;{
    const page : Page = await goToPage(url)
    const result = await page.evaluate( arr =&gt; {
      //this is where the error comes in
      let setOfElements = document.getElementsByClassName('classnamethatexists');
  
      arr = setOfElements;
      return arr;
    }
    return Promise.resolve(result);
  }
  </code></pre>
  
  <p>and the html:</p>
  
  <pre><code>&lt;div class='classnamethatexists'&gt;"This is an example of the text I want to get"&lt;/div&gt;
  &lt;div class='classnamethatexists'&gt;"This is an example of the text I want to get"&lt;/div&gt;
  &lt;div class='classnamethatexists'&gt;"This is an example of the text I want to get"&lt;/div&gt;
  &lt;div class='classnamethatexists'&gt;"This is an example of the text I want to get"&lt;/div&gt;
  </code></pre>
  
  <p>is there a way for the function to not return undefined;</p>