Q&A
Best approach for testing file downloads in Playwright?
Ajitesh MohantaAmbassador
2w ago 755 0
I need to test that a CSV export button downloads the correct file with the right data. Our app generates the file server-side and streams it.
I've tried `page.waitForEvent('download')` and it works sometimes, but I'm not sure how to:
- Assert on the file contents (not just that a download happened)
- Handle cases where the download URL is a redirect chain
- Make this reliable in headless CI
Any patterns or utility functions you'd recommend?