wait_for
parameter, ZenRows continuously monitors the page during JavaScript rendering until the target element becomes visible in the DOM. This ensures that critical content has loaded before capturing the HTML, regardless of the duration of the loading process.
js_render=true
to function, as it operates within the browser environment during JavaScript rendering.wait_for
parameter with a CSS selector to your JavaScript rendering request:
price
appears on the page before capturing the HTML content. The waiting time adapts automatically to the actual loading speed. The waiting time automatically adapts to the actual loading speed, up to a maximum of 3 minutes.
Inspect the site using browser DevTools
Verify your selector
document.querySelectorAll('your_selector')
in the browser consoleTips
.class
or #id
[data-testid="item"]
data-*
.original_status=true
allowed_status_codes=404,500
display: none
) js_instructions
to simulate a click or scroll action first.wait_for
selector that appears earlier in the loading process. Alternatively, switch to our Scraping Browser, which offers longer session times and allows you to manipulate requests more deeply through Puppeteer or Playwright.wait
parameter:
scrapingcourse.com/ecommerce/
, and your request fails with a 422 error while your wait_for
CSS selector is:
Selector | Example | Use Case |
---|---|---|
.class | .price | Wait for an elements with class “price” |
#id | #main-content | Wait for an element with ID “main-content” |
[data-attr] | [data-loaded="true"] | Wait for attribute presence |
[attr^="val"] | [id^="item-"] | Attribute starts with “item-” |
[attr$="val"] | [src$=".png"] | Attribute ends with “.png” |
A > B | .list > .item | Direct child of a parent |
A B | .list .item | Any descendant item inside a parent |
A, B | .price, .discount | Match either .price or .discount |
:nth-child(n) | li:nth-child(2) | Select the 2nd child (or any Nth) of its parent |
:first-child | div:first-child | First child of a parent element |
:last-child | div:last-child | Last child of a parent element |
wait_for
parameter doesn’t increase the request cost. You pay the JavaScript Render (5 times the standard price) regardless of the wait value you choose.
Can I use XPath instead of CSS selectors?
wait_for
parameter. Please ensure that you provide a valid expression.Here’s an example based on the HTML below:$x('//your/xpath')
.What happens if the element I'm waiting for never appears?
How does wait_for differ from wait when both are specified?
wait_for
takes precedence and completely overrides the wait
parameter. ZenRows will ignore the fixed timing and only wait for the specified element to appear.What CSS selectors are supported?
How do I know if my selector is too specific or too general?
document.querySelector('your-selector')
. A good selector should reliably match the element you want without being so specific that minor page changes break it.Does wait_for work with Premium Proxy?
What's the maximum time wait_for will wait?
wait_for
parameter will wait up to 3 minutes (180 seconds) for the specified element to appear. This is the ultimate timeout limit for any ZenRows request when using the Universal Scraper API. If the element doesn’t appear within this time, you’ll receive a 422 error.