ScreenshotNeo

BlogHow-to

How to Capture a Scrolling Page Screenshot with Selenium in C#

Capture a full-page screenshot with Selenium in C#: use FirefoxDriver’s full-page API, understand Chrome’s version-specific DevTools option, and handle lazy-loaded pages.

By the ScreenshotNeo team4 October 20266 min read

To capture a full scrolling page with Selenium in C#, use FirefoxDriver’s GetFullPageScreenshot() and save the returned screenshot. Selenium’s ordinary WebDriver screenshot captures the current browsing context, so do not assume it includes content below the viewport. For Chrome, Selenium’s versioned DevTools API has a capture-beyond-viewport option; its exact setup depends on your Selenium and browser versions.

1. Capture the full page in Firefox

Selenium’s .NET FirefoxDriver provides GetFullPageScreenshot(). It returns a Selenium Screenshot; SaveAsFile saves it as PNG and overwrites an existing file at the same path.

using OpenQA.Selenium.Firefox;

var driver = new FirefoxDriver();
try
{
    driver.Navigate().GoToUrl("https://example.com");
    var screenshot = driver.GetFullPageScreenshot();
    screenshot.SaveAsFile("full-page.png");
}
finally
{
    driver.Quit();
}

This is a FirefoxDriver-specific method. Keep the driver typed as FirefoxDriver where you call it; a variable typed as IWebDriver or a ChromeDriver does not acquire this method. Confirm that your installed Selenium .NET package exposes the API.

Use a unique output path when preserving captures

Because saving overwrites an existing file, choose a unique path for each run if you need to retain prior screenshots. For example, use a timestamp or a test-run identifier in the filename. Ensure the target directory exists and that the process has write access.

2. Understand what Selenium’s standard screenshot captures

The standard screenshot route uses ITakesScreenshot.GetScreenshot():

using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;

IWebDriver driver = new FirefoxDriver();
try
{
    driver.Navigate().GoToUrl("https://example.com");
    var screenshot = ((ITakesScreenshot)driver).GetScreenshot();
    screenshot.SaveAsFile("viewport.png");
}
finally
{
    driver.Quit();
}

This captures the current browsing context. It is useful for a viewport screenshot, but it is not a guaranteed full-document capture. Use FirefoxDriver’s full-page method when that is your goal.

3. What about Chrome?

The Chrome route described by the available Selenium API evidence is browser- and package-version-specific. Selenium .NET’s generated DevTools V149 API exposes CaptureScreenshotCommandSettings.CaptureBeyondViewport, documented with a default of false. That option is a possible DevTools route; it is not a universal Selenium C# recipe or a guarantee that one initialization snippet works across Selenium and Chrome versions.

  1. Check the Selenium package version and the matching generated DevTools namespace in its API documentation.
  2. Confirm that the browser version is compatible with that DevTools API.
  3. Set the capture-beyond-viewport option for the screenshot command if the matching API provides it.
  4. Inspect the resulting image on your target page, especially if the page has lazy-loaded content or layout changes during capture.

The research for this article did not verify a complete Chrome initialization example across Selenium and browser versions. Avoid copying code for another DevTools version without checking its generated API and compatibility.

4. Handle lazy-loaded and dynamically changing pages

A full-page capture and a page that has loaded every image are separate concerns. Some pages load content only after scrolling or after a user interaction. If below-the-fold images are missing, first determine whether the page loads them only when they approach the viewport. A browser-level full-page capture does not, by itself, prove that every site has rendered all deferred content.

When scrolling is required to trigger loading, a scroll-and-stitch strategy can capture successive viewport images and combine them. This is a general approach described for browser automation; it is not a Selenium C# API guarantee. Test it against the page you need to capture. Fixed headers, sticky navigation, and other elements anchored to the viewport can appear repeatedly or create seams in stitched output.

For comparison, Playwright .NET explicitly describes FullPage = true as capturing the full scrollable page. That is a Playwright API, not a Selenium method.

5. Choose the capture method

Need Approach Key consideration
Full page in Firefox FirefoxDriver.GetFullPageScreenshot() FirefoxDriver-specific .NET method; check your installed package.
Current viewport ITakesScreenshot.GetScreenshot() Standard screenshot of the current browsing context, not a full-page guarantee.
Full page in Chrome Matching Selenium DevTools API with capture beyond viewport Version-specific; match the generated API to Selenium and Chrome.
Content appears only while scrolling Scroll and stitch successive viewport captures Can trigger lazy loading, but fixed and sticky elements can produce artifacts.

6. Troubleshooting

Symptom Likely cause What to do
GetFullPageScreenshot is not found The driver is typed as IWebDriver or is not FirefoxDriver, or the installed package does not expose the method. Use the FirefoxDriver type at the call site and check the API for the Selenium .NET package version in your project.
The image only shows the visible area The standard GetScreenshot() method was used. Use FirefoxDriver’s full-page method, or investigate the matching Chrome DevTools route for your versions.
Images or sections below the fold are absent The site defers rendering or loading until scrolling or interaction. Determine what triggers the content. If actual scrolling is necessary, try a scroll-and-stitch flow and inspect the output.
Repeated headers, seams, or duplicated elements Viewport screenshots were stitched while fixed or sticky elements stayed anchored. Inspect each segment and adapt the scrolling/stitching strategy to the page layout, or use a browser full-page capture where it suits the page.
A previous screenshot disappears SaveAsFile overwrote the file at the same destination. Generate a unique output filename for each capture you need to keep.
Chrome DevTools code does not compile or run The generated namespace or command API does not match the installed Selenium or browser version. Consult the API matching your package and verify browser compatibility before using the command.

7. Performance, reliability, and cost

There is no sourced benchmark here for capture speed or reliability across browsers and sites. Full-page images are taller and can require more memory and storage than viewport captures; measure with your own page set if those limits matter. Dynamic pages can change while rendering, and scrolling can trigger additional network requests, so use a consistent page state when comparing captures.

Selenium’s cost depends on how you run it, including browser and compute infrastructure; this guide has no benchmark or pricing figures for those costs. For reliable output, check that the saved file exists, has a nonzero size, and visually includes the expected page before treating the capture as successful.

Or skip the browser setup

ScreenshotNeo provides a screenshot API: one GET request returns an image or PDF for a URL. See the API documentation for request options.

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

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
const image = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', image));
  • Cookie banners, popups, and chat widgets are removed before the shot; each removal step can be turned off.
  • Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers report the page verdict and billing status.
  • An MCP server gives AI agents tools to take screenshots, get page information, and capture PDFs.
  • The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Sign up free for 1,000 screenshots a month with no card.

FAQ

Does Selenium’s regular screenshot method capture a full page?

Do not count on it: the standard screenshot example applies to the current browsing context. Use an explicitly full-page method for a full scrollable document.

Can I use FirefoxDriver’s full-page method through an IWebDriver variable?

The method belongs to FirefoxDriver’s .NET API. Keep a FirefoxDriver reference where you call it, or use a type-safe approach that exposes the Firefox-specific API.

Is the Chrome DevTools option available in every Selenium release?

The documented property cited here is from the generated Selenium .NET DevTools V149 API. Check the generated API and browser compatibility for your own versions.

What if the page is taller than the image viewer can display?

The capture may still be valid as an image file. Open it in an image viewer that supports tall images, or process it in sections for review.