Wait Options

Control when the screenshot is taken by configuring wait conditions and delays.

Wait Conditions

Condition Description
load Wait for window.onload event (default)
domcontentloaded Wait for DOM to be ready (faster, no images)
networkidle Wait for no network requests for 500ms

Basic Usage

{
  "url": "https://example.com",
  "wait": {
    "until": "networkidle"
  }
}

Full Configuration

{
  "wait": {
    "until": "networkidle",
    "delay": 500,
    "for_selector": ".content-loaded",
    "for_selector_mode": "visible",
    "timeout": 30
  }
}

Parameters

Parameter Type Default Description
until string load Wait condition: load, domcontentloaded, networkidle
delay integer 0 Additional delay in ms after until condition
for_selector string Wait for CSS selector to appear
for_selector_mode string visible Selector mode: visible, hidden, attached, detached
timeout integer 30 Total timeout in seconds (max 60)

Wait Until Conditions

Load (Default)

Waits for the page's load event, which fires after all resources (images, stylesheets, scripts) are loaded:

{
  "wait": {
    "until": "load"
  }
}

DOM Content Loaded

Waits for the HTML to be fully parsed. Faster but may miss lazy-loaded content:

{
  "wait": {
    "until": "domcontentloaded"
  }
}

Network Idle

Waits until there are no network requests for 500ms. Best for SPAs and dynamic content:

{
  "wait": {
    "until": "networkidle"
  }
}

Additional Delay

Add a delay after the wait condition for animations or transitions:

{
  "wait": {
    "until": "load",
    "delay": 1000
  }
}

Wait for Selector

Wait for a specific element to appear:

{
  "wait": {
    "for_selector": ".data-loaded",
    "for_selector_mode": "visible"
  }
}

Selector Modes

Mode Description
visible Element is in the DOM and visible
hidden Element is hidden or removed
attached Element is attached to DOM (may be hidden)
detached Element is removed from DOM

Wait for Loading Spinner to Disappear

{
  "wait": {
    "for_selector": ".loading-spinner",
    "for_selector_mode": "hidden"
  }
}

Timeout

Set the maximum wait time (default 30 seconds, max 60):

{
  "wait": {
    "until": "networkidle",
    "timeout": 45
  }
}

If the timeout is exceeded, the screenshot will be taken immediately (or fail if using strict mode).

GET Request Parameters

Query Param Maps to
delay wait.delay
timeout wait.timeout
GET /v1/screenshot?url=https://example.com&delay=1000&timeout=45

Common Patterns

Single Page Applications (SPAs)

{
  "url": "https://spa-app.example.com",
  "wait": {
    "until": "networkidle",
    "delay": 200
  }
}

Pages with Animations

{
  "url": "https://animated-site.example.com",
  "wait": {
    "until": "load",
    "delay": 1500
  }
}

Dynamic Data Loading

{
  "url": "https://dashboard.example.com",
  "wait": {
    "for_selector": "[data-loaded='true']",
    "timeout": 45
  }
}

Wait for Chart to Render

{
  "url": "https://analytics.example.com/chart",
  "wait": {
    "for_selector": "svg.chart-rendered",
    "for_selector_mode": "visible",
    "delay": 500
  }
}

Examples

Wait for React App

curl -X POST https://api.renderscreenshot.com/v1/screenshot \
  -H "Authorization: Bearer rs_live_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://app.example.com",
    "wait": {
      "until": "networkidle",
      "for_selector": "#root > div",
      "delay": 300
    }
  }' \
  --output app.png

See Also

Was this page helpful?