Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
First identify whether you need the visible browser viewport or the entire page: Selenium’s Firefox Python API uses different methods for those two captures. Then inspect the saved PNG’s actual pixel dimensions; a requested window size alone does not prove the screenshot has that size. There is no universal fix established for every Firefox and geckodriver version, so the reliable approach is to match the capture method to the intended image and reproduce the mismatch with your exact environment recorded.
Identify which height is wrong
“Incorrect height” can describe two different problems. A screenshot may be the right size for the visible browser area but too short for a page that extends below it. Or it may be a viewport screenshot whose saved pixel height differs from the size you expected. Those cases need different checks; changing the browser window is not a substitute for requesting a full-page capture.
| What you expected | What to check first |
|---|---|
| Only the visible browser area | Use the current-window method, then measure the saved image. |
| The whole document, including content below the viewport | Use Selenium’s full-page method and verify the resulting image height against the page. |
| A PNG with a particular width and height | Measure the PNG itself; do not infer its dimensions only from the requested window size. |
Browser window dimensions, viewport dimensions, and document extent describe different things. Decide which one your test is asserting before treating the PNG as wrong.
Choose the Selenium Firefox screenshot method
The Selenium Python Firefox WebDriver API documents save_screenshot as a screenshot of the current window. It separately documents full-page methods, including get_full_page_screenshot_as_file and save_full_page_screenshot. Use the method that corresponds to the image your test needs.
#1 Best Overall
For the current window
Call save_screenshot when the intended artifact is the currently visible browser area. A successful method call means a file was saved; still inspect its pixel dimensions and compare them with the expected capture dimensions.
For the full document
Call a full-page method when the test should include page content beyond the visible viewport. Full-page capture is not the same request as a current-window capture, even if both are described informally as a “Firefox screenshot.” Check the API documentation for the Selenium Python version installed in your environment if a full-page method is unavailable.
Rank #2
Reproduce and measure the output
The following Python example starts headless Firefox, requests a 1024×768 window, saves both capture types, reports the window size Selenium returns, and reads each PNG’s actual dimensions with Pillow. It deliberately reports the values rather than assuming they must match. Install Selenium and Pillow in the Python environment and use a Firefox/geckodriver setup compatible with that Selenium binding. The full-page call requires a Selenium version whose Firefox WebDriver exposes that method.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchfrom pathlib import Path
from PIL import Image
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.add_argument("-headless")
driver = webdriver.Firefox(options=options)
try:
driver.set_window_size(1024, 768)
driver.get("https://example.com")
print("Reported window size:", driver.get_window_size())
viewport_path = Path("viewport.png")
if not driver.save_screenshot(str(viewport_path)):
raise RuntimeError("Selenium did not save the current-window screenshot")
with Image.open(viewport_path) as image:
print("Current-window PNG dimensions:", image.size)
full_page_path = Path("full-page.png")
if not driver.get_full_page_screenshot_as_file(str(full_page_path)):
raise RuntimeError("Selenium did not save the full-page screenshot")
with Image.open(full_page_path) as image:
print("Full-page PNG dimensions:", image.size)
finally:
driver.quit()
Replace https://example.com with a page you control or a stable test fixture. A real page may load content asynchronously or vary in document length, so use a deterministic fixture when you need repeatable dimension assertions. The example’s requested window size is a diagnostic input, not a promised PNG size.
Rank #3
Interpret the measurements
- If the visible-window image is the desired artifact, compare its dimensions with the test’s actual expected viewport image. If you meant the entire page, switch to the full-page method instead of trying to enlarge a viewport capture after the fact.
- If the full-page file still has only the expected viewport height, record that separately as a full-page capture failure; do not confuse it with a current-window mismatch.
- If the method returns false, raises an exception, or no image can be opened, preserve the error and investigate saving or capture failure before diagnosing a height discrepancy.
- Keep the image dimensions beside the test output. A logged
get_window_size()result and a measured PNG size answer different questions.
Record the environment before changing versions
Screenshot dimensions can only be compared meaningfully when the capture mode and runtime stack are known. Record these fields for each reproduction:
- Operating system and version.
- Whether Firefox is running headless.
- Selenium language binding and version.
- Firefox version and geckodriver version.
- Requested window dimensions and the dimensions returned by
get_window_size(). - Whether the call was for the current window or full page.
- The saved PNG’s measured width and height, plus any exception or return value.
Mozilla’s geckodriver usage documentation discusses usage and compatibility considerations, and its supported platforms documentation notes that geckodriver has not offered full conformance with the WebDriver standard or complete compatibility with Selenium. That context is a reason to capture versions and reproduce an issue, not a diagnosis of any particular mismatch. Mozilla also says newer Firefox versions generally include more bug fixes and features; this does not establish that upgrading alone will correct a given screenshot.
Rank #4
What the historical reports do—and do not—show
A Mozilla geckodriver issue report from July 2020 described headless Firefox returning a 1024×768 value from get_window_size() while save_screenshot() produced a 1024×694 PNG. The reported stack was macOS 10.15.4, Firefox 78.0.2 (64 bit), geckodriver 0.26.0, Python 3.7, and Selenium 3.141.0. Those figures are a specific legacy reproduction, not a general measurement of Firefox screenshots today.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →A separate Mozilla Bugzilla report from 2019 described a geckodriver full-screenshot request that returned viewport height rather than full-page height, with Firefox 70.0.1 and geckodriver 0.26.0 on Windows 10. It concerned a different symptom and stack. Neither historical report proves that a current Firefox/geckodriver combination has the same defect or that an old workaround applies.
Best Value
Troubleshoot by symptom
| Symptom | Likely diagnostic branch | Next action |
|---|---|---|
| Screenshot ends at the fold, but the page continues | Capture scope may be current window rather than full document. | Use a documented full-page Firefox method and measure the resulting file. |
| PNG differs from requested window height | The requested window setting and image artifact are not interchangeable measurements. | Log returned window size and PNG pixels, then reproduce with headless status and all component versions recorded. |
| Full-page call produces viewport-height output | This is a full-page capture symptom, not necessarily a window-size symptom. | Confirm the method exists in the installed Selenium binding, retain the output and stack details, and reproduce with a stable page. |
| Full-page method is missing | The installed Python API may not expose the documented method. | Check the Firefox WebDriver API docs for the exact installed Selenium version before upgrading or changing code. |
| Image cannot be opened or dimensions cannot be read | The failure may be in capture or file output rather than height. | Check the Selenium return value or exception and verify the output path before comparing dimensions. |
| Mismatch occurs only in one run or one page | The page or environment may not be reproducible enough to isolate the cause. | Repeat on a stable test page and record the same environment fields for each run before attributing the result to Firefox. |
Or skip the browser setup
If you need screenshots as an API result rather than as part of a Selenium browser test, ScreenshotNeo is a website screenshot API and MCP server for developers. A single GET request returns an image or PDF; its API options include full-page capture. This does not replace Selenium when your test specifically needs to exercise browser automation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for the request parameters. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and each response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents using Claude, Cursor, or another MCP client. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for 1,000 free screenshots a month, with no card required.
When to call it fixed
Consider the issue resolved only when the test asserts the intended capture scope, the saved image’s measured dimensions meet that test’s expectation, and the same result can be reproduced with the environment recorded. If those conditions fail, report the exact method, stack, requested dimensions, returned window dimensions, and PNG dimensions; do not present either legacy issue as a universal explanation.
Frequently Asked Questions
Should I compare a viewport screenshot with the page’s total height?
No. A current-window capture and the full document have different scopes. Compare the image against the dimensions expected for the capture method your test actually requested.
Do the 2019 and 2020 Mozilla reports identify a current universal Firefox fix?
No. They document particular legacy stacks and symptoms. Reproduce the mismatch with your installed versions before deciding whether a version-specific change is relevant.
Quick Recap
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.

