title: Puppeteer Not Triggering Click Before Returning HTML
body: <p>My Node.js puppeteer script fills out a form successfully, but the page only accepts a "click" event on an element <em>some</em> of the time before returning the modified page content. Here's the script:</p>
  
  <pre><code>const fetchContracts = async (url) =&gt; {
      const browser = await pupeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox']});
      const page = await browser.newPage();
      const pendingXHR = new PendingXHR(page);
  
  
      await page.goto(url, { waitUntil: 'networkidle2' });
      await Promise.all([
          page.click("#agree_statement"),
          page.waitForNavigation()
      ]);
  
      await page.click(".form-check-input");
  
      await Promise.all([
          page.click(".btn-primary"),
          page.waitForNavigation()
      ]);    
  
      /// MY PROBLEM OCCURS HERE
      /// Sometimes these clicks do not register....
      await page.click('#filedReports th:nth-child(5)')
      await pendingXHR.waitForAllXhrFinished();
      await page.click('#filedReports th:nth-child(5)');
      await pendingXHR.waitForAllXhrFinished();
  
      /// And my bot skips directly here....
      let html = await page.content();
      await page.close();
      await browser.close();
      return html;
  </code></pre>
  
  <p>}</p>
  
  <p>The "pendingXHR" module is an import, which I pull in up top in my code from <a href="https://www.npmjs.com/package/pending-xhr-puppeteer" rel="noreferrer">this</a> library:</p>
  
  <pre><code>const { PendingXHR } = require('pending-xhr-puppeteer');
  </code></pre>
  
  <p>The script works on my local computer, and works <em>some</em> of the time when I upload the script to Digital Ocean. According to the page that I am crawling, these clicks initiate XHR requests, which I am attempting to wait for. Here's proof:</p>
  
  <p><a href="https://i.stack.imgur.com/NYd1b.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/NYd1b.gif" alt="enter image description here"></a></p>
  
  <p>So my question is:</p>
  
  <p>Why would these clicks <strong>not</strong> register, even though I am awaiting them and awaiting the XHR requests, before the html is pulled from the page and then returned? And why the inconsistency with this, where <em>sometimes</em> the clicks are registered and sometimes they are not? </p>
  
  <p>Thanks for your help.</p>