title: How to get all links from the DOM?
body: <p>According to <a href="https://github.com/GoogleChrome/puppeteer/issues/628" rel="noreferrer">https://github.com/GoogleChrome/puppeteer/issues/628</a>, I should be able to get all links from <em>&lt; a href="xyz" ></em> with this single line:</p>
  
  <pre><code>const hrefs = await page.$$eval('a', a =&gt; a.href);
  </code></pre>
  
  <p>But when I try a simple:</p>
  
  <pre><code>console.log(hrefs)
  </code></pre>
  
  <p>I only get:</p>
  
  <pre><code>http://example.de/index.html
  </code></pre>
  
  <p>... as output which means that it could only find 1 link? But the page definitely has 12 links in the source code / DOM. Why does it fail to find them all?</p>
  
  <p>Minimal example:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>'use strict';
  const puppeteer = require('puppeteer');
  
  crawlPage();
  
  function crawlPage() {
      (async () =&gt; {
   
   const args = [
              "--disable-setuid-sandbox",
              "--no-sandbox",
              "--blink-settings=imagesEnabled=false",
          ];
          const options = {
              args,
              headless: true,
              ignoreHTTPSErrors: true,
          };
  
   const browser = await puppeteer.launch(options);
          const page = await browser.newPage();
   await page.goto("http://example.de", {
              waitUntil: 'networkidle2',
              timeout: 30000
          });
       
   const hrefs = await page.$eval('a', a =&gt; a.href);
          console.log(hrefs);
    
          await page.close();
   await browser.close();
    
      })().catch((error) =&gt; {
          console.error(error);
      });;
  
  }</code></pre>
  </div>
  </div>
  </p>