How to Take a Full-Page Website Screenshot with Selenium in Python
Use Selenium’s Firefox WebDriver to save a full-page PNG in Python. See the browser limitation, complete example, troubleshooting, and a one-call API alternative.
To take a full-page website screenshot with Selenium in Python, use Firefox WebDriver’s get_full_page_screenshot_as_file() method. It saves the current page’s full document as a PNG. This specific method is documented for Firefox; Selenium’s Chromium Python reference documents ordinary current-window screenshots, so do not assume the Firefox method works with Chrome. Selenium Firefox WebDriver API · Selenium Chromium WebDriver API.
1. Install Selenium and prepare Firefox
Install Selenium in the Python environment you will use to run the script:
python -m pip install selenium
The example uses Selenium’s Firefox driver. You need a working Firefox installation and a Selenium setup that can start its WebDriver. Selenium’s API reference documents the screenshot call; it does not establish a compatibility matrix for every browser version or remote configuration.
2. Save the full document as a PNG
from pathlib import Path
from selenium import webdriver
url = "https://example.com"
output = Path("full-page.png").resolve()
driver = webdriver.Firefox()
try:
driver.get(url)
saved = driver.get_full_page_screenshot_as_file(str(output))
if not saved:
raise OSError(f"Could not save screenshot to {output}")
print(f"Saved full-page screenshot to {output}")
finally:
driver.quit()
The filename should end in .png. The method returns True when it saves the image and False for an I/O error. Using an absolute path makes it easier to locate the output and follows the API’s guidance to use full paths. Always quit the driver in a finally block so the browser process is closed if navigation or saving fails.
3. Choose the output form you need
Firefox’s full-page API also provides image data directly when you do not want the WebDriver method to write a file. These methods are documented on the same Firefox WebDriver API page.
# PNG bytes, for writing or passing to another Python library
png_bytes = driver.get_full_page_screenshot_as_png()
Path("full-page.png").write_bytes(png_bytes)
# Base64 text, for a data URL or another system that expects Base64
png_base64 = driver.get_full_page_screenshot_as_base64()
Use the file method for the simplest saved screenshot. Use PNG bytes when another part of your program consumes binary image data. Base64 is useful when an interface explicitly expects encoded text, but it adds encoding overhead and is larger than the original binary data.
4. Know what changes with Chromium
Selenium’s Chromium Python API documents save_screenshot() and related methods for the current window. The general Selenium screenshot example likewise uses driver.save_screenshot(). These references do not establish that those calls capture the entire document. If your requirement is specifically a full-document image, use the documented Firefox method above or choose another capture approach whose full-page behavior is documented for your environment.
from selenium import webdriver
driver = webdriver.Chrome()
try:
driver.get("https://example.com")
driver.save_screenshot("current-window.png")
finally:
driver.quit()
This Chromium example is an ordinary current-window screenshot, not a promise of full-page capture. For browser-specific behavior, consult the relevant Chromium API reference.
5. Handle page timing and capture edge cases
- Navigate to the intended URL first. The screenshot methods capture the current window, so ensure the driver is on the page you intend to save.
- Dynamic pages may still be changing. A successful navigation call does not by itself prove that every application-specific element has finished rendering. If the page depends on asynchronous content, synchronize with the page condition your application requires before calling the screenshot method. The cited full-page API does not promise that lazy content has been loaded or that animations have settled.
- Capture the correct tab and state. The API describes a screenshot of the current window. If your script opens or switches tabs, verify the active browsing context and page before capture.
- Plan for filesystem errors. Ensure the destination directory exists and the process can write to it. Check the method’s boolean result.
- Use PNG for this method. The full-page file method is documented to save PNG and expects a filename ending in
.png.
6. Troubleshooting
| Symptom | Likely cause | What to do |
|---|---|---|
AttributeError for get_full_page_screenshot_as_file |
The driver is not Firefox, or the method is unavailable in the browser/driver setup. | Use webdriver.Firefox() for this documented method. Chromium’s cited Python API documents current-window screenshot methods, not this Firefox full-page method. |
The method returns False |
The image could not be written, commonly because of a bad path or filesystem permissions. | Resolve the output path, create its parent directory if needed, and confirm the process can write there. |
| Screenshot file is not where expected | A relative path was saved relative to the process’s working directory. | Print or inspect Path(...).resolve() and use the resulting absolute path. |
| Screenshot shows an unexpected page state | The page was still updating, or the wrong tab/window was active. | Wait for the application-specific content you need and confirm the current page before capture. The API reference does not guarantee readiness of dynamic content. |
| PNG extension warning or mismatched filename | The output name does not end in .png. |
Use a .png filename for this API. |
| Browser fails to start | Firefox or the WebDriver setup is missing or not usable in the execution environment. | Check that Firefox is installed and that Selenium can start its Firefox WebDriver; then retry with the same minimal script. |
7. Performance, reliability, and cost
A full-document image can contain substantially more pixels than a screenshot of the visible window, so image size and capture work depend on the page dimensions and content. The cited Selenium API does not publish performance benchmarks, size limits, or guarantees for every page. Keep the output location writable, close each driver session, and add application-specific readiness checks for pages that render asynchronously. Selenium itself is browser automation; infrastructure and browser costs depend on where you run it.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request can return an image or PDF. Its screenshot API accepts a URL and supports full-page capture; see the ScreenshotNeo API documentation.
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,
)
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}`);
ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot. Bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month, with no card.
FAQ
Does the full-page method save JPEG?
The documented file method saves a PNG. Convert the resulting image separately if you need another format.
Can I get the screenshot without creating a file?
Yes. Use get_full_page_screenshot_as_png() for bytes or get_full_page_screenshot_as_base64() for Base64 text.
Is save_screenshot() equivalent to a full-page screenshot?
The cited Selenium docs describe it as a screenshot of the current window. They do not establish full-document capture for that call.
Does this guide capture every lazy-loaded image?
The cited Firefox API reference does not make that guarantee. If the page loads images as the visitor scrolls, verify that the required content is loaded before capture.


