Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a Cucumber test that already drives Chrome through Selenium, use Chrome DevTools Protocol (CDP) Page.captureScreenshot with captureBeyondViewport enabled. That option allows capture beyond the visible viewport; a normal viewport screenshot does not do this. The exact Selenium call depends on your language binding and installed versions, so use the generated DevTools API that matches your project rather than copying a method signature from another Selenium version.

What makes a screenshot full-page?

A standard screenshot captures the portion of the page visible in the browser viewport. A full-page screenshot must include content outside that area. With CDP, the relevant command is Page.captureScreenshot; its captureBeyondViewport option defaults to false in the protocol documentation. Set it to true for a capture that extends beyond the viewport.

The command returns image data as a base64-encoded string over JSON. Your test must decode that data and write the resulting bytes to an artifact file. CDP documents PNG, JPEG, and WebP formats; quality is relevant to lossy formats such as JPEG and WebP.

For pages whose full dimensions matter to your test or artifact policy, Page.getLayoutMetrics returns cssContentSize, the size of the scrollable page area in CSS pixels. You can use those dimensions to reason about the expected capture size. You do not need to request metrics merely to understand that a full-page capture differs from a viewport capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Samsung 14" Galaxy Chromebook Go Laptop PC Computer, Intel Celeron N4500 Processor, 4GB RAM, 64GB Storage, ChromeOS, XE340XDA-KA2US, Student Laptop, Silver
  • SLIM. LIGHTWEIGHT. READY TO GO: The all-new slim design is perfect for busy lives on the go.
  • SKILLFULLY DESIGNED. MILITARY TOUGH: Built with premium craftsmanship to withstand the occasional drop or ding.
  • ALL-DAY, ALL-IN-ONE CHARGING: Power through your school day – and beyond – with a long-lasting 12-hour battery.¹
  • 3X FASTER THAN THE PREVIOUS GENERATION OF WIFI: Crush your schoolwork in record time with Wi-Fi that’s three times faster than the previous generation of Wi-Fi.
  • YOUR PHONE AND CHROMEBOOK WORK BETTER TOGETHER: Easily transfer files between devices, and control your phone right from your Chromebook.

Choose the CDP API for your project

Use the Chrome session that Cucumber’s existing Selenium setup created. Opening another browser inside the step can capture a different session, with different cookies, navigation state, or test data.

Selenium provides generated DevTools APIs, including screenshot command settings such as CaptureBeyondViewport and Clip. The generated API and its signatures are versioned, however. The protocol’s tip-of-tree reference changes frequently and does not guarantee backwards compatibility. The right implementation therefore depends on the Selenium language binding and DevTools version available in your project, as well as the Chrome version it controls.

  1. Identify the project’s binding and versions. Check the Selenium dependency and the Chrome version used by the test environment. Do not assume an example for Java, JavaScript, or .NET has the same API in another binding—or even in another version of the same binding.
  2. Find that binding’s generated DevTools API. Use the API version included with your Selenium dependency and locate its equivalents of Page.captureScreenshot and, if needed, Page.getLayoutMetrics.
  3. Use the active test driver. In the Cucumber step, obtain the Selenium-managed Chrome driver from the project’s existing scenario or dependency-injection setup.
  4. Set the capture options. Enable captureBeyondViewport, choose an image format, and set lossy-format quality only if appropriate. Use a clip only when the test intentionally needs a specific region rather than the whole page.
  5. Decode and save the result. Decode the returned base64 field and write its bytes to the test artifact location using the project language’s file API.
  6. Verify the artifact. Check that the file exists, is non-empty, opens as the chosen image type, and includes content below the initial viewport.

Why this article does not give one universal step definition

The title does not specify a Cucumber language binding, and Selenium’s generated DevTools signatures vary by binding and version. A code sample that names a particular driver constructor, DevTools session method, generated command class, or scenario-injection mechanism would silently assume a project setup that may not match yours. The stable implementation boundary is the protocol operation and its data flow: invoke the CDP command through the installed Selenium binding, decode the base64 screenshot data, and save it as an artifact.

When adapting an example for your project, confirm each of these details against the generated API actually installed:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
ASUS 2026 15" FHD IPS Chromebook, Intel Processor Up to 2.80GHz, 4GB DDR4, 128GB Storage, HDMI, Super-Fast WiFi, Chrome OS, Pastel Blue, Renewed
  • Intel Processor Up to 2.80GHz, 4GB DDR4, 128GB Storage
  • 15" FHD IPS Display, Intel UHD Graphics
  • 1x USB Type C, 1 x USB Type A, 1x Headphone/Microphone Combo Jack, HDMI
  • Super Fast WiFi and Bluetooth, Integrated Webcam
  • Chrome OS, AC Charger Included, Pastel Blue
  • How the Selenium driver exposes or creates a DevTools session.
  • How the binding represents the Page domain and screenshot parameters.
  • How the response exposes base64 image data.
  • How the project writes test artifacts and makes them available after a run.
  • Whether the installed Chrome and Selenium DevTools versions support the option you intend to use.

This is a protocol-based implementation path, not a tested, binding-specific Cucumber step definition. Chrome’s protocol documentation explicitly warns that its tip-of-tree reference can change and offers no backwards-compatibility guarantee. Resolve APIs against the versions in your own test environment before committing the step.

Decide what the artifact should contain

Whole scrollable page

Enable captureBeyondViewport when the desired artifact should extend outside the viewport. If page dimensions are relevant, inspect cssContentSize from Page.getLayoutMetrics. These dimensions are in CSS pixels; they are not by themselves a promise about the final file’s pixel dimensions, which can also depend on capture settings and device scale.

A selected region

CDP screenshot settings include Clip. Use it only if the test needs a defined region. A clip changes the requested capture area; it is not a substitute for asking for the whole page when that is the requirement.

Format and quality

Choose PNG when you need a lossless image. JPEG and WebP are lossy formats and accept a quality setting. Check the image format and quality options exposed by your binding rather than assuming every wrapper exposes every protocol parameter in the same way.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep the capture reliable in a test suite

  • Capture at a deliberate point. Take the screenshot after the scenario has reached the page state you intend to document. A full-page command does not make a page’s application content ready on its own.
  • Keep ownership of the browser clear. Let the existing scenario driver and its lifecycle manage Chrome. Avoid creating a second session solely for the screenshot.
  • Use a predictable artifact path. Write to the location your test runner or CI system collects. Include scenario context in filenames if the suite captures multiple artifacts, and avoid filenames that overwrite earlier captures.
  • Check large pages deliberately. If a page has a large scrollable area, inspect its layout metrics and verify the resulting image. Do not infer successful full-page coverage merely from a successful command response.
  • Keep protocol use version-aware. Pin and verify compatible Selenium and Chrome versions in the test environment. Recheck generated DevTools APIs when upgrading either component.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot missing, partial, or unusable screenshots

The image shows only the viewport

Check that captureBeyondViewport is explicitly enabled in the generated command settings. The protocol default is false. Also verify that the binding call you are using actually sends that setting rather than merely accepting it in an unused local object.

The DevTools method or parameter does not compile

The example likely targets a different Selenium binding or generated DevTools version. Inspect the API shipped with the dependency in your project and use its matching command and parameter types. Do not treat the tip-of-tree protocol reference as a stable Java, JavaScript, or .NET method signature.

The command succeeds but no image file appears

CDP returns base64 data over JSON; it does not itself write the test artifact. Decode the response’s image data and pass the decoded bytes to your language’s file-writing API. Confirm that the output directory exists and is writable by the test process.

The saved file cannot be opened

Check that you decoded the base64 value rather than writing its encoded text into a file, and that the extension matches the format requested. Ensure the response was not empty before treating the write as successful.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
HP Chromebook 14 Laptop, Intel Celeron N4120, 4 GB RAM, 64 GB eMMC, 14" HD Display, Chrome OS, Thin Design, 4K Graphics, Long Battery Life, Ash Gray Keyboard (14a-na0226nr, 2022, Mineral Silver)
  • FOR HOME, WORK, & SCHOOL – With an Intel processor, 14-inch display, custom-tuned stereo speakers, and long battery life, this Chromebook laptop lets you knock out any assignment or binge-watch your favorite shows..Voltage:5.0 volts
  • HD DISPLAY, PORTABLE DESIGN – See every bit of detail on this micro-edge, anti-glare, 14-inch HD (1366 x 768) display (1); easily take this thin and lightweight laptop PC from room to room, on trips, or in a backpack.
  • ALL-DAY PERFORMANCE – Reliably tackle all your assignments at once with the quad-core, Intel Celeron N4120—the perfect processor for performance, power consumption, and value (2).
  • 4K READY – Smoothly stream 4K content and play your favorite next-gen games with Intel UHD Graphics 600 (3) (4).
  • MEMORY AND STORAGE – Enjoy a boost to your system’s performance with 4 GB of RAM while saving more of your favorite memories with 64 GB of reliable flash-based eMMC storage (5).

The capture is unexpectedly small or cropped

Review whether the command includes a Clip setting and whether that region is intentional. If full-page dimensions are important, request Page.getLayoutMetrics and inspect cssContentSize in CSS pixels before diagnosing the output.

The test behaves differently after an upgrade

Compare the Selenium-generated DevTools API and Chrome version before and after the change. CDP tip-of-tree documentation is not a backwards-compatible contract; use the protocol/API version appropriate to the browser and Selenium release you run.

Or skip the browser setup

If you need a screenshot from a URL rather than from the exact live session controlled by your scenario, ScreenshotNeo provides a screenshot API and MCP server. Its API returns an image or PDF from one GET request. This example saves a WebP response:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options and response details. Cookie banners are accepted and removed along with known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. An MCP server exposes take_screenshot, get_page_info, and capture_pdf to AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up free for ScreenshotNeo to start with 1,000 screenshots a month and no card.

Cost and fit for a Cucumber workflow

CDP is the direct route when the artifact must represent the page state of the Chrome session your scenario is testing. It keeps capture within the test’s browser context, but requires version-aware integration and artifact handling in your binding. An HTTP screenshot API is a different workflow: it captures a URL through a service, not necessarily the authenticated or scenario-specific state in your existing browser. Choose based on whether you need the test session itself or a URL-based capture.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.