title: How to download file with puppeteer using headless: true?
body: <p>I've been running the following code in order to download a <code>csv</code> file from the website <code>http://niftyindices.com/resources/holiday-calendar</code>:</p>
  
  <pre><code>const puppeteer = require('puppeteer');
  
  (async () =&gt; {
  const browser = await puppeteer.launch({headless: true});
  const page = await browser.newPage();
  
  await page.goto('http://niftyindices.com/resources/holiday-calendar');
  await page._client.send('Page.setDownloadBehavior', {behavior: 'allow', 
  downloadPath: '/tmp'})
  await page.click('#exportholidaycalender');
  await page.waitFor(5000);
  await browser.close();
  })();
  </code></pre>
  
  <p>with <code>headless: false</code> it works, it downloads the file into <code>/Users/user/Downloads</code>. with <code>headless: true</code> it does NOT work.</p>
  
  <p>I'm running this on a macOS Sierra (MacBook Pro) using puppeteer version <code>1.1.1</code> which pulls Chromium version <code>66.0.3347.0</code> into <code>.local-chromium/</code> directory and used <code>npm init</code> and <code>npm i --save puppeteer</code> to set it up.</p>
  
  <p>Any idea whats wrong?</p>
  
  <p>Thanks in advance for your time and help,</p>