## TL;DR

The export click either missed its target or the script did not wait for the download. Wait for the download event explicitly, use stable selectors for the export button, and verify the CSV before processing it.

## Error

```text
playwright failed when agent tried exporting the expense csv
```

## Steps

1. Replace any fixed sleep before the export click with a wait for the button to be actionable. Expected: the click lands on the right element.
2. Wrap the click in a download-event wait: start waiting for the download before clicking. Expected: the script captures the file instead of racing it.
3. Save the download to a known path and check the file exists with nonzero size. Expected: a real file on disk.
4. Parse the CSV header and confirm the expected columns are present. Expected: the export has the right shape.
5. If the button selector breaks often, prefer the export API if the tool offers one. Expected: no selector maintenance.

## When to use

- Playwright fails on an expense CSV export step.
- The failure is in clicking or capturing the download.

## When not to use

- The CSV exports but has wrong data (check export filters).
- An API export is available (use it instead of the browser).

## Tool compatibility

- Playwright; Expensify, Concur, Ramp CSV exports.

## Variant phrasings

### CSV export failed in Playwright

Same failure, shorter wording.

### Download event never fired

The specific Playwright symptom.

## Why it happens

Export buttons render after data loads, and downloads are asynchronous OS-level events. Scripts that click too early or never listen for the download event miss the file.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_Dsby4NfnZlDxPLfhgitTtQ
