title: How to use Puppeteer's page.click inside a forEach loop?
body: <p>I want to make <a href="https://github.com/puppeteer/puppeteer" rel="nofollow noreferrer">Puppeteer</a> click on some tabs based on the number of items in an array called <code>tabs</code>:</p>
  
  <pre><code>;(async () =&gt; {
    const browser = await puppeteer.launch({
      headless: true
    })   
  
    const page = await browser.newPage()
    await page.goto(`https://www.example.com`)
  
    const tabs = ['tab1', 'tab2', 'tab3']
  
    tabs.forEach((tab, index) =&gt; {
      await page.click(`.postab-container li:nth-of-type(${ index + 1 }) a`)
    })
  })()
  </code></pre>
  
  <p>But I get this error:</p>
  
  <blockquote>
  <pre><code>await page.click(`.postab-container li:nth-of-type(${ index + 1 }) a`)
        ^^^^
  
  SyntaxError: Unexpected identifier
  </code></pre>
  </blockquote>
  
  <p>It seems like the <code>forEach</code> statement is messing up <code>page</code>.</p>
  
  <p>What's the correct way of doing this?</p>