There is a set of use cases when you want to fail screenshot rendering and retry it if the content of the page contains a string.
Fail rendering if the content contains a string
There is a set of use cases when you want to fail screenshot rendering and retry it if the content of the page contains a string.
For example:
fail_if_content_contains=Coming Soon
for your screenshot requests allows you to automatically ignore captures showing “Coming Soon” on a product page, ensuring you only get notified when the page updates to show the product is available for purchase.fail_if_content_contains=Maintenance
, thereby skipping any maintenance messages displayed on your application’s homepage.You don’t pay for failed and cached screenshots with ScreenshotOne.
That’s exactly what you need the option fail_if_content_contains
for.
Let’s quickly see how it works and how you can use it. Let’s first render the example.com page:
https://api.screenshotone.com/take?access_key=<your access key>&url=https://example.com
The result is:
Now, let’s try to fail it:
https://api.screenshotone.com/take?fail_if_content_contains=Illustrative+Examples+In+Documents&access_key=<your access key>&url=https://example.com
The result is:
{ "is_successful": false, "error_message": "The page content contains the requested string `Prior` by the `fail_if_content_contains` option. If it seems to be a mistake or not what you expected, please, reach out to `support@screenshotone.com` as quickly as possible, and will assist and try to resolve your problem.", "error_code": "content_contains_requested_string"}
As you might notice, the match is case insensitive, it is done for simplicity.
Interviews, tips, guides, industry best practices, and news.
A new version of the ScreenshotOne API has been just deployed. It allows you to set both locale and language of the browser when rendering screenshots with one simple option.
Since a few months ago, it has been possible to check errors in the dashboard request log and get explanations and more details in the documentation. But!
Daily, I work as hard as I can to ensure that ScreeenshotOne is the best screenshot API out there possible. But I rarely share updates but trust me, a ton of them might go unnoticed. Let's fix this situation.
Exhaustive documentation, ready SDKs, no-code tools, and other automation to help you render website screenshots and outsource all the boring work related to that to us.