Woodander Media
LAST 24 HOURS ON TOP Rolling 24 hours 1 Today's #1 is up for grabs $5 First bid takes the spot Take #1 for $5 →
NEW IN MEDIA · FOUNDER STORY From the Gallery Floor to NatWest: Building the Fine Art Market’s First Bank-Agnostic Fintech
Woodander Discover Explore projects and businesses Add your project → Woodander TOP Competitive project rankings Claim a spot → Woodander Media News, stories and analysis Write a story → Woodander Market Advertising and partnerships List your channel → Woodander SEO Tools and content growth Check my website → Woodander Outreach Find relevant opportunities Build my route →
Guide Developer tools

A browser reported a download. Did your automation actually get the file?

An export step in a browser workflow can report a filename while the next step has no file to read. I reproduced that gap with a 33-byte CSV called `synthetic-inventory.csv`. The same Playwright test saw a download start in three environments. The differences appeared only when i...

Zuch Huang Published Dec 4, 2026 · 2 min read

An export step in a browser workflow can report a filename while the next step has no file to read. I reproduced that gap with a 33-byte CSV called synthetic-inventory.csv. The same Playwright test saw a download start in three environments. The differences appeared only when it checked whether the download finished and tried to read the saved copy.

Separate the click, the download and the saved file

I ran Playwright 1.65.2 with locally launched Chrome 158.0.8127.108, with the same Chrome started by Playwright's launchServer() and reached via chromium.connect(), and with a disposable hosted Chrome 158.0.8127.88 reached via connectOverCDP(). The WebSocket server test ran on loopback. It checks Playwright's native transport without adding a hosting or network variable. The hosted Chrome used an isolated browser with outbound access disabled. The CSV contained only synthetic data. I ran the same check with both an inline link and a fixture HTTP response carrying Content-Disposition: attachment. Playwright served the HTTP fixture directly to the browser without an external site. Both fixtures gave the same results.

Connection Download event download.failure() Artifact readable from the runner
Local Chrome Yes null saveAs() saved all 33 bytes
Playwright browser server Yes null path() threw on the remote connection. saveAs() saved all 33 bytes
Hosted Chrome over CDP, this fixture Yes canceled saveAs() failed and the runner had no CSV

The copies saved by the first two runs matched the fixture byte for byte and were still readable after their browser contexts closed. The hosted result applies to the tested configuration and does not identify the reason for the cancellation. Test the browser and connection mode your job actually uses.

Make the file check part of the workflow

Start listening for the event before clicking. Then check the terminal status, save to a path you control and read the resulting bytes before marking the export complete. Here is the core check for a test that already has a Playwright page. Pass a new output path within your job's artifact directory.

const assert = require('node:assert/strict');
const { readFile } = require('node:fs/promises');

async function verifyInventoryExport(page, outputPath) {
  const csv = 'item,quantity\nsynthetic-widget,3\n';
  const encoded = Buffer.from(csv).toString('base64');
  const html = `<a href="data:text/csv;base64,${encoded}" ` +
    'download="synthetic-inventory.csv">Export inventory</a>';
  await page.goto(`data:text/html,${encodeURIComponent(html)}`);

  const pending = page.waitForEvent('download', { timeout: 10_000 });
  await page.getByRole('link', { name: 'Export inventory' }).click();
  const download = await pending;
  assert.equal(download.suggestedFilename(), 'synthetic-inventory.csv');

  const failure = await download.failure();
  if (failure) throw new Error(`Browser download failed (${failure})`);
  await download.saveAs(outputPath);
  assert.deepEqual(await readFile(outputPath), Buffer.from(csv));
}

In a real job, verify the type and expected contents of the file before handing it to the next step. Set a job-level deadline for the download and transfer. If failure() reports a cancellation, inspect the browser's download policy. If it reports success but the runner cannot read the file, check the connection transport and the host's documented artifact export options. Playwright documents the distinction between path() and saveAs().

Save important files before you close a test context or pause a hosted browser. A persistent browser profile can restore sign-in state while its downloads folder starts empty. The Cloudbrowser lifecycle documentation describes that boundary for the hosted browser I used. I work on Cloudbrowser and used AI assistance for the fixture and manuscript editing.

Zuch Huang More from this author →

Free SEO check

How does your site look to Google?

Paste your address and see what to fix first. No account needed.

More in Developer tools →
Ready to launch? Add your project to Discover — free. Add your project
Woodander Media keep growing.