title: Cannot download file while headless: true, works when headless: false [Puppeteer]
body: <p>Im running a script that logs into an authenticated session on a website and clicks a button to download an excel file. Im able to run it with no problems while <code>headless: false</code>, but when <code>headless:true</code>, the file does not download.</p>
  <p>My research suggests that the browser is closing before the download completes possibly? Ive added a wait of about 15 seconds, which is much longer than it should need to download the file, but still not getting anything. Another solution I tried was manually removing the <code>HeadlessChrome</code> substring from the userAgent in case the site was blocking it, but that didnt work either. Is it okay to use <code>headless:false</code> in a script that is used in a production web application deployed on Heroku?</p>
  <pre><code>async function getData () {
    try {
      const wait = (ms) =&gt; new Promise(resolve =&gt; setTimeout(resolve, ms))
      const browser = await puppeteer.launch();
      const page = await browser.newPage();
   
      await page.goto('&lt;url&gt;');
      //login
      await page.type('#username',username);
      await page.click('#signIn');
      await wait(4000)
      await page.type('#password',password);
      await page.click('#signIn');
     
      await page.waitForNavigation();
      await page.keyboard.press('Enter'); //click out of any pop up
      // //go to merchandising page
      await page.click('#m_69-link');
      await page.waitForSelector('#ExcelReportButton', {visible: true})
      //click on export as excel icon
      await wait(4000)
      await page.click('#ExcelReportButton');
      await wait(15000)
      await browser.close();
    } catch (error) {
      console.log(error)
    }
  };
  </code></pre>