cypress-io / cypress-example-recipes

Various recipes for testing common scenarios with Cypress

Home Page:https://on.cypress.io/examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

File download that uses document.location.href does not work

bahmutov opened this issue · comments

See https://github.com/cypress-io/cypress-example-recipes/tree/add-href-download-example where I have added a failing test.

The application downloads the file using

document.querySelector('[data-cy=download-csv-href]').addEventListener('click', () => {
  console.log('about to download CSV file')
  document.location.href = 'records.csv'
})

The CSV file is actually downloaded, but then the test runner times out waiting for the page to load

Screen Shot 2021-02-23 at 11 33 20 AM

I think this is a very common problem with file downloads many people are reporting