Skip to main content
The wait_for parameter allows you to delay rendering until a specific element attribute is present on the page.

Overview

When rendering pages with dynamic content, you may need to ensure certain elements are fully loaded before capturing the page. The wait_for parameter lets you specify an element and attribute to wait for before proceeding with rendering.

Parameter details

object
Delays rendering until a specific element attribute is present on the page

Usage

Behavior

The rendering process will wait until the specified attribute exists on the element matching the provided CSS selector. This is useful for ensuring that dynamic content has finished loading before the PDF is generated.

Use cases

This parameter is particularly useful for:
  1. Single-page applications: Wait for specific UI components to finish rendering before capturing the page.
  2. Lazy-loaded content: Ensure images, data, or other resources that load asynchronously are fully rendered.
  3. Custom loading indicators: Wait for your application’s own loading state to indicate completion.

Examples

Waiting for content to load

Waiting for images to load

Waiting for application state

Combining with evaluate_js

You can use evaluate_js to set the attribute that wait_for is looking for: