# Capturing a single-page app: a failure diary

> Eight blank or half-drawn screenshots of one small single-page app, why each happened, and which wait option fixed it, with the real results.

Failure diary by Serghei Pogor, founder of CurlShot (https://curlshot.com/about/serghei-pogor). Published 21 November 2026. Page for people: https://curlshot.com/blog/spa-screenshot-failure-diary

A single-page app comes back blank or half-drawn when the picture is taken before the app's own data has arrived. In a test of one small app, waiting for a data element (wait_for_selector=[data-row]) showed rows in 7 of 9 situations. The two it missed, a route change by click and an API that answered 500, cannot be fixed by waiting. A selector that also matches the skeleton, networkidle, and a fixed delay each failed or cost time in at least one case. CurlShot documents the same options on its waiting page.

## Key facts

- wait_until=domcontentloaded showed grey skeleton bars in all 9 test situations, because it skips the settle step the renderer adds after the load event.
- The default wait caught data that arrived in 3.5 s or less on all 3 captures of each case, and missed data at 6 s on all 3. Between 4 s and 4.5 s the same request gave a skeleton on 2 of 3 captures.
- wait_until=networkidle did not help an app that starts its fetch 1.5 s after load: the picture was a skeleton on 2 of 2 captures, because the network was already quiet.
- A selector that matches the skeleton (.table) is satisfied at once. A selector for a data row showed rows in 7 of 9 situations, the same as delay=5 but without waiting 5 s on a fast page.
- Playwright treats a faded-out element as visible, so a selector fired while the rows were still at 0.58 to 0.95 opacity. A 1 s delay or a ready attribute set after the fade gave 1.00 on 4 of 4.
- A click for a route change showed a skeleton with every wait, because the waits run before the click. Request the route's own address instead.

## The app
The app is one HTML file. It has a header with two links, a router built on history.pushState, an Orders page and a Reports page. Each page draws a table of grey skeleton bars first, fetches its data from a local server after the page has loaded, then swaps the skeleton for rows. The server answers after a delay the test sets. Each case was captured in a new Chromium 153.0.8010.12 context through Playwright 1.63.0 at 1280 x 1024, by replaying the renderer wait steps in the order of its source: load, the bot-check wait, the settle step, wait_for_selector, delay, click, the blank-page check, the picture. The settle step and the bot-check functions are the renderer files, imported unchanged. The server shared its machine with other jobs (load average 5 to 10 on 6 cores), so every time below is slower than on a quiet machine and the exact edges move from run to run.

## The diary
### 1. A page of grey bars at domcontentloaded

Verdict: Failed. Sent: `wait_until=domcontentloaded`.

What came back: The header, the heading and a table of 8 rows of grey bars (32 skeleton bars, no data rows). It came back in about 1 s. The same on all 9 situations: none showed a data row.

Why: A single-page app draws its skeleton the moment its script runs, which is before the load event, and it asks for its data after that. This option also skips the settle step, the short wait the renderer adds after the load event, so nothing is left to catch the data.

Fix: Leave it for the cases where speed matters more than the page, or pair it with a wait for an element (the last entry shows that pair).

### 2. The default holds, until the data is slow

Verdict: Flaky. Sent: `(nothing: wait_until=load, the default)`.

What came back: With data after 2.5, 3 and 3.5 s, all 3 captures of each showed rows. At 4 s and 4.5 s only 1 of 3 did. At 5 s all 3 did, though the first run had caught a skeleton at 5 s. At 6 s none did (0 of 3).

Why: After the load event the renderer waits up to 3 s for the network to go quiet, then up to 3 s for the picture to stop changing. A skeleton that does not change counts as a picture that stopped changing. Data that lands near the end of that window is caught on one capture and missed on the next, which is worse than a clean failure.

Fix: Do not depend on the default for an app whose data can take more than about 3 s. Wait for a data element instead (entry 4).

### 3. networkidle is a guess about the future

Verdict: Failed. Sent: `wait_until=networkidle`.

What came back: The app waited before it asked its API. After 0.3 s both the default and networkidle showed rows 2 of 2 times. After 0.8 s the default showed rows 1 of 2 and networkidle 2 of 2. After 1.5 s and 3 s, neither did: 0 of 2 each. In the first run a delay of 2 s fixed the 1.5 s case.

Why: Playwright counts the network as idle after at least 500 ms with no connections. An app that starts its fetch later than that, because it loads a chunk first, checks a flag or waits for a timer, is idle before it asks for anything. The picture then holds still, and the settle step stops waiting.

Fix: Name the thing you are waiting for. A delay works here but guesses how long; a data element does not guess.

### 4. A selector that matches the skeleton

Verdict: Trap. Sent: `wait_for_selector=.table`.

What came back: The request returned at once because the skeleton is also a table with the class table. With data in 5 s, 9 s and with the late fetch, the picture was the skeleton. The same request with wait_for_selector=[data-row] showed rows in 7 of 9 situations; the two it missed are entries 7 and 8.

Why: wait_for_selector resolves on the first visible match. Skeleton markup often reuses the classes of the real content so the layout does not jump.

Fix: Pick something that exists only after the data: a row, a total, an attribute the app sets when it is ready. If the page is yours, add one.

### 5. Visible, but not yet there: the fade-in

Verdict: Failed. Sent: `wait_for_selector=[data-row]`.

What came back: Data after 6 s, rows fading in over 0.6 s. Four captures read the opacity of the rows just before the picture: 0.95, 0.71, 0.91, 0.58. With delay=1 added, 4 of 4 were at 1.00. With a selector for an attribute the app sets when the fade ends, 4 of 4 were at 1.00.

Why: Playwright treats an element with opacity 0 as visible. The selector matched when the rows were put into the page, not when they finished appearing.

Fix: Add a short delay, turn animations off with reduced_motion, or select the element that the app marks after its transition.

### 6. A fixed delay: too short here, too long there

Verdict: Works, costs time. Sent: `delay=2 and delay=5`.

What came back: delay=5 got rows in 7 of 9 situations and delay=2 in 6. It missed the 9 s case. On the page whose data came in 0.3 s the picture took 2.6 s by default, 4.0 s with delay=2 and 7.0 s with delay=5, one capture each.

Why: A delay is a sleep after the other waits end. It is long enough for the slow page and a waste on the fast one, and it is fixed.

Fix: Keep delay for what nothing can see, such as a chart drawing itself. For data, wait for the data.

### 7. A route change by click

Verdict: Failed. Sent: `click=a[href="/reports"] with each of the nine waits`.

What came back: All nine pictures showed the Reports heading over grey bars: 16 skeleton bars, 0 rows. That includes delay=5, which took 15.5 s.

Why: In the renderer, the waits run first and the click after them. After the click there is a pause of 250 ms and a wait of up to 3 s for the load event, which a client-side route change never fires. The data of the new route has not been asked for yet when the picture is taken, so a wait set on the request cannot wait for it.

Fix: Request the route by its own address. The same data, opened as the Reports address, showed rows in 8 of 8 ways that wait (all but domcontentloaded), with the revenue line in place. This needs a host that serves the app for deep links, which single-page app hosts normally do.

### 8. The picture is right; the data never came

Verdict: Trap. Sent: `wait_for_selector=[data-row]`.

What came back: With the API answering 500, the default capture showed a red box that says the orders could not be loaded. Every wait for a data element ended in selector_not_found when the lab timeout ran out, status 422.

Why: No wait changes what a server answers. The page drew an error, which is what it was asked to do.

Fix: Treat selector_not_found as a signal that the page is broken, not as a reason to wait longer. If the API needs a header or a cookie the capture does not send, add it with headers or cookies.

## Slow data and the default wait
| Data after | Captures with rows (of 3) |
| --- | --- |
| 2.5 s | 3 |
| 3.0 s | 3 |
| 3.5 s | 3 |
| 4.0 s | 1 |
| 4.5 s | 1 |
| 5.0 s | 3 |
| 6.0 s | 0 |

## A fetch that starts late
| App asks its API after | Default (of 2) | networkidle (of 2) |
| --- | --- | --- |
| 0.3 s | 2 | 2 |
| 0.8 s | 1 | 2 |
| 1.5 s | 0 | 0 |
| 3.0 s | 0 | 0 |

## Every way against every situation
| Situation | Default (load) | domcontentloaded | networkidle | delay 2 | delay 5 | selector .table | selector [data-row] | selector [data-ready] | commit + [data-ready] |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Data in 0.3 s | Rows | Skeleton | Rows | Rows | Rows | Rows | Rows | Rows | Rows |
| Data in 2.5 s | Rows | Skeleton | Rows | Rows | Rows | Rows | Rows | Rows | Rows |
| Data in 5 s | Skeleton | Skeleton | Rows | Rows | Rows | Skeleton | Rows | Rows | Rows |
| Data in 9 s | Skeleton | Skeleton | Rows | Skeleton | Rows | Skeleton | Rows | Rows | Cut at 10 s |
| Fetch starts at 1.5 s | Skeleton | Skeleton | Skeleton | Rows | Rows | Skeleton | Rows | Rows | Rows |
| Rows fade in | Rows | Skeleton | Rows | Rows | Rows | Rows | Rows | Rows | Rows |
| Route by address | Rows | Skeleton | Rows | Rows | Rows | Rows | Rows | Rows | Rows |
| Route by click | Skeleton | Skeleton | Skeleton | Skeleton | Skeleton | Skeleton | Skeleton | Skeleton | Skeleton |
| API answers 500 | Error box | Skeleton | Error box | Error box | Error box | No match | No match | No match | No match |

Rows: the picture shows the data. Skeleton: grey bars. Error box: the page drew its error. No match: selector_not_found. Cut at 10 s: the lab timeout ended a wait that would have succeeded with the default 30 s. The same selector with a 30 s timeout showed rows at 10.8 s.

Waits that showed rows: default 4 of 9, networkidle 6, delay 2 6, delay 5 7, selector .table 4, selector [data-row] 7, selector [data-ready] 7, domcontentloaded 0.

## The request to end on
```bash
curl -G "https://curlshot.com/api/v1/screenshot" \
  --data-urlencode "access_key=YOUR_ACCESS_KEY" \
  --data-urlencode "url=https://app.example.com/reports" \
  --data-urlencode "wait_for_selector=[data-row]" \
  --data-urlencode "timeout=30" \
  --output reports.png
```
Wait for an element that exists only after the data, and set `timeout` above the slowest answer your API gives. Add `delay` of 1 for a fade-in, or select the element your app marks when it is done. The options are explained in [waiting and timing](https://curlshot.com/docs/waiting); try a page on the [URL to image tool](https://curlshot.com/tools/url-to-image) or see [pricing](https://curlshot.com/pricing) for the free plan.

## How it was run
On 12 November 2026. The app is one HTML file. It has a header with two links, a router built on history.pushState, an Orders page and a Reports page. Each page draws a table of grey skeleton bars first, fetches its data from a local server after the page has loaded, then swaps the skeleton for rows. The server answers after a delay the test sets. Each case was captured in a new Chromium 153.0.8010.12 context through Playwright 1.63.0 at 1280 x 1024, by replaying the renderer wait steps in the order of its source: load, the bot-check wait, the settle step, wait_for_selector, delay, click, the blank-page check, the picture. The settle step and the bot-check functions are the renderer files, imported unchanged. The server shared its machine with other jobs (load average 5 to 10 on 6 cores), so every time below is slower than on a quiet machine and the exact edges move from run to run. No call to the CurlShot API was sent in these runs. A selector wait in run 1 used a 10 s timeout; the 9 s case was rerun with 30 s.

## Questions

### Why is my screenshot of a React, Vue or Angular app blank or full of grey bars?

The picture was taken before the app drew its data. In the test, domcontentloaded gave a skeleton every time, and the default wait gave one when the data took 6 s. Wait for an element that exists only after the data with wait_for_selector, and set timeout above your API's slowest answer.

### Does wait_until=networkidle fix a single-page app?

Only when the app asks for its data at once. Playwright counts the network as idle after 500 ms without connections, so an app that fetches later is idle first. In the test networkidle failed 2 of 2 times when the fetch started 1.5 s after load.

### Should I use delay or wait_for_selector?

Use wait_for_selector for data: it ends when the element appears. In the test delay=5 got rows in 7 of 9 situations but took 7.0 s on a page that was ready in a fraction of that, and delay=2 missed the 9 s case. Keep delay for things no selector can see, such as an animation.

### How do I screenshot a route of a single-page app?

Request the route's own address. A click on a link showed a skeleton with every wait in the test, because the waits run before the click and the click is followed by only a 250 ms pause. Opening the same route by address showed rows with every wait except domcontentloaded. The host has to serve the app for deep links.

### Why does wait_for_selector fail with selector_not_found?

No visible element matched before the timeout. Either the selector is wrong, the element is hidden, or the data never came. In the test an API that answered 500 made every data selector time out, so check what the page shows with no wait before you raise the timeout. CurlShot returns status 422 for this error.

## Sources

1. Playwright documentation, "Auto-waiting and actionability checks": https://playwright.dev/docs/actionability (checked 12 November 2026)
2. Playwright documentation, "Page: waitForLoadState and the networkidle state": https://playwright.dev/docs/api/class-page (checked 12 November 2026)

## Go deeper

- [URL to image tool](https://curlshot.com/tools/url-to-image)
- [Screenshot API](https://curlshot.com/tools/screenshot-api)
- [Waiting and timing](https://curlshot.com/docs/waiting)
- [Pricing](https://curlshot.com/pricing)

## Read next

- [Lazy images and full-page captures, measured](https://curlshot.com/blog/lazy-images-full-page-scroll-test.md): Five ways a page loads pictures on scroll, seven scroll rules, 105 runs in Chromium: which full-page captures come back with every picture.
- [Why website screenshots look wrong, and the fixes](https://curlshot.com/blog/why-website-screenshots-look-wrong.md): A field guide to 11 ways a website screenshot goes wrong, from blank lazy images to cookie banners and cut-off pages, with the cause and the fix for each.
- [15 curl errors on a screenshot call, with fixes](https://curlshot.com/blog/curl-errors-screenshot-api.md): 15 curl errors from real runs of a screenshot call: the exact message, what it means, how to check it and the fix. Paste yours to look it up.
