title: Puppeteer infinite scrolling
body: <p>I have a website to scrape and what I need to scrape is inside a <strong>div</strong> that has an id <strong>left_container_scroll</strong> that contains multiple <strong>a tags</strong>. This div has the infinite scroll on it and I can't make it work. I am trying to make the program scroll in that div.</p>
  
  <p>I have tried to do something like this, but I get an error: Evaluation failed: ReferenceError: elem is not defined</p>
  
  <pre><code>htmlTag = '#left_container_scroll';
  
  //I think I am doing something wrong here
  let elem = await page.evaluate((htmlTag)=&gt; {
      return document.querySelector(htmlTag);
  })
  
  previousHeight =  await page.evaluate("elem.scrollHeight");
  await page.evaluate("window.scrollTo(0,elem.scrollHeight)");
  await page.waitForFunction(`elem.scrollHeight &gt; ${previousHeight}`);
  </code></pre>