The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →To screenshot one part of a page with Selenium in Python, locate the element and call its screenshot() method. It saves that element as a PNG:
from selenium.webdriver.common.by import By
element = driver.find_element(By.CSS_SELECTOR, "main .result-card")
element.screenshot("partial.png")
Here, driver is an already-created Selenium WebDriver instance. Replace the example CSS selector with one that matches the element you want to capture.
Save a screenshot of one element
After navigating to the page and ensuring the target is in the state you want to capture, find it with a stable locator and call WebElement.screenshot():
from selenium.webdriver.common.by import By
# driver is an already-created Selenium WebDriver instance.
element = driver.find_element(By.CSS_SELECTOR, "main .result-card")
saved = element.screenshot("partial.png")
if not saved:
raise OSError("Could not save the element screenshot")
The filename should end in .png. The method returns True if it saves successfully and False if it encounters an I/O error. See Selenium’s WebElement Python API for the method details.
#1 Best Overall
Choose a reliable locator
The selector above is illustrative. Prefer a page-specific ID or CSS selector that identifies the intended element consistently. If the selector matches the wrong element, Selenium will capture that match instead; check the locator against the page under test.
Wait for the intended page state
Locate and capture the element only after the page has reached the state you intend to record. Dynamic pages may render or update content after navigation. Selenium’s screenshot API documents the capture operation, but there is no single wait strategy established for every page or application; choose a wait condition that matches your page.
Rank #2
Choose the right capture scope and output
“Partial screenshot” can mean an element image, a crop of the visible window, or a full-document image. Selenium’s element method directly addresses the first case. These scopes and output forms are not interchangeable:
| What you need | Python API | Output or scope |
|---|---|---|
| One located page element | element.screenshot("element.png") |
Saves the element screenshot as a PNG file. |
| PNG image data for one element | element.screenshot_as_png |
Returns PNG bytes for downstream code. |
| Base64 representation for one element | element.screenshot_as_base64 |
Returns a base64 string. |
| Current browser window | driver.get_screenshot_as_file("window.png") |
Saves a screenshot of the current window, not a full-document or element-only screenshot. |
| Full document in Firefox | driver.get_full_page_screenshot_as_file(...) |
Firefox’s Python API documents separate full-document screenshot methods. |
For driver-level current-window methods, see Selenium’s WebDriver Python API. Firefox full-document methods are documented in the Firefox WebDriver Python API. Do not treat a current-window capture as a full-page screenshot.
Recommended Free Tools
Use PNG bytes or base64 when a file is not the next step
Use element.screenshot_as_png when another part of your program needs image bytes, or element.screenshot_as_base64 when the data must be represented as base64. The WebElement API documents all three element screenshot forms.
When the target is an arbitrary rectangle
An element screenshot is appropriate when the region corresponds to a DOM element. If you need a pixel rectangle that does not correspond to an element, the cited Selenium APIs do not establish a general crop method; do not assume the element method captures arbitrary coordinates.
Troubleshoot an element screenshot
- The file is missing or not written: check the output path and directory permissions, use a
.pngfilename, and inspect the method’s Boolean return value. - The wrong area was captured: verify that the locator identifies the intended element on the current page and that it does not resolve to a different match than expected.
- The image shows an earlier or incomplete page state: wait for the target content to reach the state you want before capturing. The appropriate condition depends on the application.
- The result differs across layouts or browsers: inspect the page and browser state and verify the element and output. The cited API references do not establish universal guarantees for off-screen elements, clipping, or rendering behavior across drivers.
- You expected the whole page: a driver-level screenshot is for the current window. Firefox documents separate full-document methods; use a method whose scope matches the desired image.
Or skip the browser setup
If you need a screenshot through an API rather than managing a Selenium browser session, ScreenshotNeo offers a one-request capture. Its cookie and consent handling removes known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. ScreenshotNeo also provides an MCP server with screenshot tools for AI agents.
For a full-page capture of a target URL, the cURL request is:
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Replace YOUR_API_KEY with your key and replace the target URL as needed. See the ScreenshotNeo API documentation for request options, including element capture. ScreenshotNeo is a website screenshot API and MCP server by Yorker Media; it is an alternative to Selenium when you want an API or agent-driven capture rather than setting up a browser in your own script.
The Free plan includes 1,000 shots per month with no card required; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.
Frequently Asked Questions
Does Selenium save a WebElement screenshot as a PNG?
Yes. The WebElement screenshot method saves a PNG file; use a filename ending in .png.
Can I use Selenium’s element screenshot method for any rectangular crop?
It is intended for a located page element. The cited APIs do not establish a general method for capturing arbitrary pixel coordinates that do not correspond to an element.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteQuick 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.




