Wait for element
Ensure dynamic content is fully loaded by waiting for a specific element attribute before rendering
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
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:
-
Single-page applications: Wait for specific UI components to finish rendering before capturing the page.
-
Lazy-loaded content: Ensure images, data, or other resources that load asynchronously are fully rendered.
-
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: