Screenshot API error ยท HTTP 422
Selector not found
selector_not_found
error_on_selector_not_found=true, no element of the page matched selector within 5 seconds, so the render failed instead of capturing the viewport.How to recognize it
The API answers with status 422 and a JSON body with the message and the error.code selector_not_found, for example:
HTTP/1.1 422
Content-Type: application/json
{
"error": {
"code": "selector_not_found",
"message": "No element of the page matches the selector."
},
"message": "No element of the page matches the selector."
}Common causes
- A typo in the selector, or a class name or id that the site changed.
- An element that appears only after a click, a scroll, a consent dialog or a login.
- An element inside shadow DOM, which plain CSS selectors do not reach.
How to fix it
- Check the selector in the browser’s console on the same page:
document.querySelector("..."). - For shadow DOM, use
>>>(#app >>> .chart) orpierce/(pierce/.chart). - Wait for late content with
wait_for_selector, or bring it up withactions(a click, a scroll) before the capture. - Without
error_on_selector_not_found, a missing element captures the viewport instead.
Billing
The first 25 failure conditions a day are free for each account (selector_not_found, content_condition_failed, request_failed and action_failed together, per UTC day). After that, each counts as one request, like a render. One exception: when an evaluate step of actions or the scripts ran in the page before the render failed, it is billed as one request, because that code could read the page, unless the failure is ours.
Related parameters
selector, error_on_selector_not_found, wait_for_selector, actions. Each is described in the take endpoint reference.
Every response carries an X-Request-Id header. If this page does not explain the error, write to support@screenshotbase.com with that id. All statuses: status codes.
Other API errors
Screenshot API
Take screenshots from your code
screenshotbase renders any website in a real browser and returns the image: full page or viewport, any device size, retina, from 100+ countries, with cookie banners and ads hidden.
/v1/take documentation Screenshot API All documentation
300 free screenshots every month. No credit card required.
GET https://api.screenshotbase.com/v1/take?url=https://example.com&full_page=true
# Response: the image (PNG, JPG, WebP, AVIF or GIF)
curl -G "https://api.screenshotbase.com/v1/take" \
--data-urlencode "url=https://example.com" \
-d viewport_width=1280 -d viewport_height=800 \
-d format=png \
-H "apikey: YOUR-API-KEY" \
-o screenshot.png