Screenshot Function
This function will take a screenshot of the page you specified and return the image in .png
or .jpg
format.
You can take one or more screenshots, in parallel, on different browsers and operating systems without having to write any code.
Simply use the HTTP requests listed below in your app to generate a live screenshot of any page, on a real TestingBot browser.
Example
curl -X POST https://cloud.testingbot.com/screenshot?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN10 \
-H 'Content-Type: application/json' \
-d '{"url":"https://testingbot.com"}' > screenshot.png
This simple example will run a Puppeteer script on our service and do the following:
- Start a Headless Browser (latest version) on our cloud
- Connect with Puppeteer to the Browser and navigate to the URL you specified
- Take a screenshot of the page
-
Return the
PNG data
back to you -
The
PNG data
is saved in a file calledscreenshot.png
Specifying browser and version
See the example below to specify on which platform configuration you'd like to take your screenshot on. You can specify a browserName
, version
and platform
.
Screenshot Options
You can specify additional options with this function call to customize the screenshot taking.
This function call can use any of the Puppeteer page.screenshot options.
curl -X POST https://cloud.testingbot.com/screenshot?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN10 \
-H 'Content-Type: application/json' \
-d '{"url":"https://testingbot.com", "options":{"fullPage":true}}' > screenshot.png
Authenticate options
You can specify the page.authenticate credentials.
curl -X POST https://cloud.testingbot.com/screenshot?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN10" \
-H 'Content-Type: application/json' \
-d '{"url":"https://testingbot.com", "authenticate":{ "username": "user", "password": "passwd" }}' > screenshot.png
Goto options
You can specify the page.goto options and add timeout
and waitUntil
settings.
curl -X POST https://cloud.testingbot.com/screenshot?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN10 \
-H 'Content-Type: application/json' \
-d '{"url":"https://testingbot.com", "gotoOptions":{ "waitUntil": "networkidle2" }}' > screenshot.png
Extra Headers
You can specify the page.setExtraHTTPHeaders options to add extra HTTP headers to the request our Headless Browser makes.
curl -X POST https://cloud.testingbot.com/screenshot?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN10 \
-H 'Content-Type: application/json' \
-d '{"url":"https://testingbot.com", "extraHeaders":{ 'foo': 'bar' }}' > screenshot.png
Disable Javascript
You can disable Javascript with the page.setJavaScriptEnabled option.
curl -X POST https://cloud.testingbot.com/screenshot?key=YOUR_KEY&secret=YOUR_SECRET&browserName=chrome&version=latest&platform=WIN10 \
-H 'Content-Type: application/json' \
-d '{"url":"https://testingbot.com", "javascriptEnabled":false}' > screenshot.png
Add Tags
-
You can add additional
style tags
with the page.addStyleTag option. -
You can add additional
script tags
with the page.addScriptTag option.