web_screenshot
Capture a PNG screenshot of a web page to show its layout and design, and cross-check the rendered pixels against the page's text from the same browser visit.
Instructions
A PNG screenshot of a web page. The fourth tool of the module.
WHEN TO CALL. You need to SHOW a page to a person — the layout, the design, what the text does not carry. And you need to CROSS-CHECK: the shot and the text are obtained in one browser visit but by different routes — the pixels are drawn by the layout engine, the text comes from the DOM. A disagreement between them catches what neither route sees alone.
WHEN NOT TO CALL. You need the text of the page — that is web_read, many times cheaper. A screenshot costs a browser launch.
WHAT IT RETURNS. png_base64 — the shot itself; bytes — its size; page_text — the text of THE SAME visit, up to max_chars; page_text_chars — the length of the whole text, which may be greater; page_text_truncated; browser_version.
HOW TO READ THE ANSWER — two things, and they are DIFFERENT.
shot_taken — THE SHOT WAS TAKEN: the browser is alive, the page loaded.
expected_found — WHAT WE EXPECTED IS ON THE PAGE (when
expectwas given). A shot can be taken flawlessly and show the wrong thing: a stub, a captcha, an error page. Do not confuse these two fields — a page that honestly failed a check and a browser that never opened are different events.
A signal worth seeing: there is a shot and page_text_chars is near zero — the page drew, and has nothing to say.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | the page address | |
| expect | No | markers that must be present on the page. They are checked against the TEXT of the same visit: a screenshot cannot check itself. Not found gives expected_found=false, and the shot is still taken | |
| full_page | No | false by default — the visible area. true captures the whole page and costs more | |
| max_chars | No | how much of the page text to return beside the shot; 2000 by default. The text is here to be compared with the picture — for the whole document call web_read, which has a cursor |