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

Use Firefox WebDriver’s full-document screenshot method, not the ordinary viewport method. In Python, create a webdriver.Firefox() instance, open the URL, and call get_full_page_screenshot_as_file() with an absolute path ending in .png. The method returns False when the file cannot be written, so check the result.

Capture an entire page with Firefox Selenium

This complete example uses Selenium’s Firefox driver, which communicates with Firefox through Marionette:

from pathlib import Path
from selenium import webdriver

url = "https://example.com/long-page"
out = Path("/absolute/path/page.png")

with webdriver.Firefox() as driver:
    driver.get(url)
    ok = driver.get_full_page_screenshot_as_file(str(out))
    if not ok:
        raise OSError(f"Screenshot could not be written: {out}")

print(f"Saved full-page screenshot to {out}")

get_full_page_screenshot_as_file() is a Firefox-specific Selenium Python operation for a full document. It writes PNG data to the path you provide and reports whether the write succeeded. Use a real absolute path, including the .png extension; a relative or unwritable path is a common reason for a False result.

Install Selenium and let Selenium Manager find the driver

Install or upgrade Selenium in the Python environment that will run the script:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python -m pip install --upgrade selenium

Recent Selenium releases can use Selenium Manager to locate a compatible Firefox driver. Firefox itself must be installed. In a locked-down CI image, container, or older Selenium setup, you may need to manage Firefox and geckodriver versions yourself. Keep Selenium, Firefox, and geckodriver compatible; full-page behavior is not guaranteed to be identical across arbitrary combinations.

Use an explicit output directory

Create the destination directory before capture when your script runs in a fresh workspace:

from pathlib import Path
from selenium import webdriver

out_dir = Path("artifacts").resolve()
out_dir.mkdir(parents=True, exist_ok=True)
out_file = out_dir / "page.png"

with webdriver.Firefox() as driver:
    driver.get("https://example.com/long-page")
    if not driver.save_full_page_screenshot(str(out_file)):
        raise OSError(f"Firefox could not save {out_file}")

save_full_page_screenshot() is the other documented high-level Firefox method for the same full-document result. Treat it as an alternative spelling, not as a viewport capture method.

Why save_screenshot() usually captures only the viewport

The ordinary get_screenshot_as_file() (often called through save_screenshot()) is a separate WebDriver operation. It captures what is visible in the current viewport. Scrolling the page and taking several viewport shots is not equivalent to Firefox’s full-document operation: you must stitch images yourself, and fixed or sticky elements can appear repeatedly.

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

For a complete document, use one of these Firefox methods instead:

  • driver.get_full_page_screenshot_as_file(filename)
  • driver.save_full_page_screenshot(filename)
  • driver.get_full_page_screenshot_as_png() when you need PNG bytes
  • driver.get_full_page_screenshot_as_base64() when another system expects Base64 text

Choose a file, PNG bytes, or Base64

Write directly to a PNG file

File output is the simplest choice for test artifacts, documentation, and local inspection. Always check the Boolean return value:

from selenium import webdriver

with webdriver.Firefox() as driver:
    driver.get("https://example.com/long-page")
    written = driver.get_full_page_screenshot_as_file("/tmp/example-full.png")
    if not written:
        raise OSError("The screenshot file was not written")

Keep PNG data in memory

The bytes method avoids an intermediate file. You can send the result to object storage, an HTTP client, or an image-processing library:

from selenium import webdriver

with webdriver.Firefox() as driver:
    driver.get("https://example.com/long-page")
    png_bytes = driver.get_full_page_screenshot_as_png()

if not png_bytes.startswith(b"x89PNG"):
    raise ValueError("Firefox did not return PNG data")
# Example: write later, upload, or process in memory
with open("/tmp/example-full.png", "wb") as image_file:
    image_file.write(png_bytes)

Return Base64 text

Base64 is useful when the receiving API accepts text or when you are embedding the image in a JSON response. It is larger than binary PNG data, so prefer bytes for direct file or upload operations:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import base64
from selenium import webdriver

with webdriver.Firefox() as driver:
    driver.get("https://example.com/long-page")
    encoded = driver.get_full_page_screenshot_as_base64()

png_bytes = base64.b64decode(encoded)
with open("/tmp/example-full.png", "wb") as image_file:
    image_file.write(png_bytes)

What Marionette’s full=True means

Selenium’s Firefox methods are the practical interface most Python programs should use. At the lower Marionette layer, the screenshot command has explicit arguments:

png_bytes = marionette.screenshot(format="binary", full=True)

When no element is supplied, full=True requests the complete frame (the document), while full=False requests only the viewport. Marionette sends these values in its WebDriver:TakeScreenshot command. The format can request binary PNG data, a Base64 representation, or a SHA-256 hash, depending on the Marionette client API you are using.

This lower-level call assumes you already have a connected Marionette client. For normal Selenium automation, prefer webdriver.Firefox() and the documented full-page methods; it avoids coupling your code to a separate Marionette connection setup.

Capture one element instead of the whole document

A full-document screenshot and an element screenshot solve different problems. When an element is supplied to Marionette, the image is limited to that element’s bounding rectangle rather than the entire page. The scroll argument controls whether Marionette scrolls the element into view first.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
# Lower-level Marionette semantics
component_png = marionette.screenshot(
    format="binary",
    full=False,
    element=element_id,
    scroll=True,
)

Use an element capture for a card, chart, or component. Do not expect it to include content outside the element’s bounds. If you need the whole page, omit the element and request full=True.

Timing and page-state considerations

driver.get() returns after the browser’s normal page-load navigation completes, but a page can still change afterward. JavaScript-rendered sections, delayed fonts, animations, and lazy content may affect the pixels you capture. The APIs do not promise a particular result for every such page, so make the page state deterministic when accuracy matters.

  • Navigate to the exact URL, including any required query string.
  • Wait for an application-specific condition with Selenium before capturing rather than relying on an arbitrary sleep.
  • Disable or stabilize animations in the test environment when visual comparisons require repeatability.
  • Verify how your target page behaves with sticky headers, lazy-loaded images, and cross-origin frames; these are page-specific rendering concerns, not guarantees of the screenshot API.

For example, wait for a known result element:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait

with webdriver.Firefox() as driver:
    driver.get("https://example.com/long-page")
    WebDriverWait(driver, 20).until(
        lambda browser: browser.find_element(By.CSS_SELECTOR, "main[data-ready='true']")
    )
    if not driver.get_full_page_screenshot_as_file("/tmp/ready-page.png"):
        raise OSError("Screenshot write failed")

Troubleshoot common failures

The image contains only the visible viewport

Check that you called get_full_page_screenshot_as_file() or save_full_page_screenshot(), not get_screenshot_as_file() or save_screenshot(). The ordinary operation is a separate viewport capture.

The method returns False or raises a file error

  • Use an absolute path ending in .png.
  • Confirm the parent directory exists and is writable by the process.
  • Check that the destination is not a directory, read-only mount, or invalid network path.
  • Try writing to a local temporary directory to distinguish a browser problem from a filesystem problem.

Firefox will not start or the session fails

Confirm Firefox is installed and that your Selenium, Firefox, and geckodriver versions are compatible. Upgrade Selenium first, then review the driver and browser versions in the environment running the script. Headless CI systems also need a functioning Firefox installation and sufficient shared memory and display configuration for their chosen mode.

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.

The screenshot is captured before dynamic content appears

Wait for a reliable DOM condition, network completion signal exposed by the application, or a specific element. A fixed sleep can work for a known page but is slower and less reliable when load times vary.

The page is extremely tall or the file is unexpectedly large

A full-document PNG contains every captured pixel, so image dimensions and memory use grow with page height and viewport width. Capture only the required element when possible, reduce the browser window width for the job, or process PNG bytes without keeping multiple copies in memory. Test your longest pages in the same environment used for production runs.

Operational choices for automation

Need Recommended operation Important check
Archive a page as an image get_full_page_screenshot_as_file() Absolute writable .png path and Boolean result
Upload without a temporary file get_full_page_screenshot_as_png() Handle PNG bytes and avoid unnecessary copies
Send through a JSON or text API get_full_page_screenshot_as_base64() Decode or transmit Base64 as required by the receiver
Capture a component Element screenshot with Marionette element and scroll Result is the element rectangle, not the full document
Capture what a user currently sees Ordinary viewport screenshot method It intentionally excludes off-screen document content

Or skip the browser setup

If you only need a rendered screenshot and do not need to drive Firefox locally, ScreenshotNeo is a website screenshot API and MCP server. It accepts the cookie or consent banner as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

One GET request returns PNG, JPEG, WebP, or a PDF. See the ScreenshotNeo API documentation for all options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const bytes = new Uint8Array(await res.arrayBuffer());

The free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 screenshots, and every feature is available on every plan. Create a free ScreenshotNeo account to try the API.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

FAQ

Does a full-page screenshot include content in an iframe?

The screenshot is rendered by Firefox, but the APIs do not guarantee identical treatment of every cross-origin or embedded frame. Verify the exact page and security context you need to archive.

Can I request JPEG output from Selenium’s Firefox full-page method?

The Selenium Firefox methods described here save or return PNG data. If your workflow requires another format, convert the PNG after capture or use a service that returns the required format.

Is a full-document capture the same as scrolling and stitching images?

No. Firefox’s full-page operation is a dedicated browser screenshot command. Manual scrolling and stitching is a separate workflow with its own alignment and fixed-element problems.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Frequently Asked Questions

Does a full-page screenshot include content in an iframe?

The screenshot is rendered by Firefox, but the APIs do not guarantee identical treatment of every cross-origin or embedded frame. Verify the exact page and security context you need to archive.

Can I request JPEG output from Selenium’s Firefox full-page method?

The Selenium Firefox methods described here save or return PNG data. If your workflow requires another format, convert the PNG after capture or use a service that returns the required format.

Is a full-document capture the same as scrolling and stitching images?

No. Firefox’s full-page operation is a dedicated browser screenshot command. Manual scrolling and stitching is a separate workflow with its own alignment and fixed-element problems.

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.

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