title: how to loop over divs with the same class with Puppeteer
body: <p>Using puppeteer to scrape a page Im able to get the contents from a list of divs with the same class and nested list of divs within those i.e.</p>
  <pre><code>&lt;div class=&quot;parent&quot;&gt;
      &lt;div class=&quot;child&quot;&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;parent&quot;&gt;
      &lt;div class=&quot;child&quot;&gt;&lt;/div&gt;
      &lt;div class=&quot;child&quot;&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;parent&quot;&gt;
      &lt;div class=&quot;child&quot;&gt;&lt;/div&gt;
      ...
  &lt;/div&gt;
  ...
  </code></pre>
  <p>now my problem is i need to reiterate over the list and run the page.click() on the child class divs to open lightboxes, select an element in the lightbox to click then run the page.pdf() on.</p>
  <p>I currently have a for loop over the parent class divs, and an inner for loop over the child class divs. I'm not sure how to select the right div with the for loop index values as there is no nth-of-class etc.</p>
  <p>I simply want to run something like</p>
  <pre><code>for (let a = 0; a &lt; data.length; a++) {
      for (let b = 0; b &lt; data[a].length; b++) {
          await page.click('.parent[a] .child[b]');
          // other code here...
      }
  }
  </code></pre>
  <p>to open the lightbox, then a</p>
  <pre><code>await page.waitForSelector('.ReactModal')
  </code></pre>
  <p>to scrape the lightbox html and the run</p>
  <pre><code>await page.pdf({
      path: dir + &quot;/&quot;+ filename, 
      format: 'A4' 
  });
  </code></pre>
  <p>Any guidance would be appreciated as to the possible approaches would be.</p>