Skip to main content

Screenshots

The screenshot mutation allows for simple navigation to a site and capturing a screenshot. Browserless will respond with either a binary or base64 encode of a png or jpg (depending on parameters).

On this collection we'll look at:

BQL Schemas

For more details on BQL mutations, refer to the BrowserQL Schema reference pages.

Rest API

Taking Screenshots can also be done with Browserless Rest API. For endpoint details, parameters, and code samples, see the Browserless REST API.

Basic Usage

mutation Screenshot {
goto(url: "https://example.com") {
status
}

screenshot(omitBackground:true) {
base64
}
}
Waiting for Elements

For more reliable screenshots, it's important to wait for the site and elements to be ready before capturing. Learn more about BrowserQL's built-in wait methods in our Waiting for Things documentation.

Setting HTML Content

You can set the HTML content of the page to render dynamically generated content.

mutation Screenshot {
content(html: "<h1>Hello, World!</h1>") {
status
}

screenshot(type: webp) {
base64
}
}

Next Steps

Ready to take your screenshot automation to the next level? Explore these key areas: