title: Puppeteer getting response from pdf download link
body: <p>I'm automating regression testing for a website and one of the tasks is to verify pdf downloads. I'm using Puppeteer and Chromium for this. I've found that it's rather difficult to download files in headless mode. Instead of downloading the file, I thought it might be prudent to look for a response from the page and the size of the file. My issue: when I try to navigate to the page, nothing seems to happen. I receive a timeout error. Here is the code I'm attempting to use:</p>
  
  <pre><code>const filename = new RegExp('\S*(\.pdf)');
  await page.waitForSelector('#download-pdf', {timeout: timeout});
  console.log('Clicking on "Download PDF" button');
  const link = await page.$eval('#download-pdf', el =&gt; el.href);
  await Promise.all([
      page.goto(link),
      page.on('response', response =&gt; {
          if(response._headers['content-disposition'] === `attachment;filename=${filename}`){
              console.log('Size: ', response._headers['content-length']);
          }
      })
  ]);
  </code></pre>
  
  <p>EDIT</p>
  
  <p>If anyone understands how <code>page.goto()</code> ignores <code>.pdf</code> pages, that will be very useful to me.</p>
  
  <p>Let me define the problem better. Upon clicking the <code>download pdf</code> button on the webpage, an event is triggered that generates the pdf file and sends the user along a unique url. This url is destroyed after a short period. In order to get to this point, I believe that I must use <code>page.click()</code> to trigger the event and generate the url. However, <code>page.click()</code> is also attempting to navigate to the pdf url, which is rejected in headless mode. What I need to do is get the url and test for a response from it.</p>