--wait-for
- CLI
- --wait-for
- REST
- wait_for
Sets when the page is captured.
| Value | When |
|---|---|
load | The window. event |
ready | The DOMContentLoaded event |
networkidle0 | After the load event, once no request has started or finished for 500ms |
networkidle2 | After the load event, once no request has started or finished for 1 second, with up to two still open |
js:NAME_ | When a CustomEvent of that name fires on window: js:my_ captures once the page runs window. |
css:SELECTOR | When a DOM element matching this selector exists on the page |
| Any number | That many seconds after DOMContentLoaded: 5, 2., or 0 for no delay |
Delays
Append seconds to networkidle0 or networkidle2 to wait that much longer once the network is idle: networkidle0:2.5.
Redirects
To capture the destination of a redirect that fires after the page loads, such as a delayed meta-refresh or a timed script redirect, set a number of seconds larger than the redirect delay.
Example
zshot --wait-for 5 https://zshot-cli.com/{
"url": "https://zshot-cli.com/",
"output_type": "png",
"wait_for": "5"
}curl -X POST http://127.0.0.1:3000/ \
-H "Content-Type: application/json" \
-d '{"url":"https://zshot-cli.com/","output_type":"png","wait_for":"5"}' \
-o page.png