## TL;DR

Driving the Salesforce UI to export a duplicate report is brittle (layout changes, lazy loading, session quirks). Get the same data via API: query the duplicate record sets or run the report via the analytics API. UI automation is the last resort, not the first tool.

## Error

```text
Browser automation failed: export button not clickable; the duplicate report page never finished loading.
```

## Steps

1. Identify what the report shows: duplicate record sets for an object. Expected: the underlying data definition.
2. Reproduce it via API: query DuplicateRecordSet and DuplicateRecordItem, or run the report through the analytics API. Expected: the same rows, programmatically.
3. Export the API results to your file format. Expected: the deliverable without a browser.
4. Delete the browser automation path. Expected: one fewer brittle dependency.
5. If some data is truly UI-only, scope the browser automation to that slice and guard it with retries. Expected: minimal, hardened UI use.

## When to use

- UI export automation breaks on Salesforce pages.
- An agent drives the browser for data available via API.
- After Salesforce UI updates break selectors.

## When not to use

- Data genuinely unavailable via API (rare; verify first).
- API query problems (fix the query).

## Tool compatibility

- Salesforce analytics API and duplicate management objects.
- Playwright or Selenium as the fallback only.

## Variant phrasings

### export button not clickable

Use the API instead of the UI.

### ui export automation broke

Same migration; API first.

## Why it happens

Salesforce's UI changes constantly (Lightning updates, lazy loading), while the API is versioned and stable. UI automation inherits all the UI's volatility.

## Edge cases

- Some report types have no direct API equivalent; the analytics API covers most.
- API row limits differ from UI exports; page or use Bulk API for large sets.
- Permissions for API access may differ from UI; verify the integration user's access.

## Provenance

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