Recommended Free Tools
Use Selenium’s driver-level screenshot method to capture the current browsing context, or the element-level method to capture one element. Python saves directly with save_screenshot(); Java uses TakesScreenshot; C# uses ITakesScreenshot. The examples below show both approaches, explain frame selection, and save PNG files.
Choose a page or element screenshot
A driver screenshot captures the current browsing context. Use it for the page view Selenium is currently controlling. An element screenshot targets one located element, so you do not have to capture a page and crop it yourself.
Do not assume a normal driver screenshot is always a full-page image. Screenshot extent can depend on the browser and driver; the cited Selenium examples do not establish a universal full-page rule. See Selenium’s window and tab documentation for the language examples.
Python
Save the current browser screenshot
Install Selenium and have Chrome available with a compatible driver setup, then run:
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
from selenium import webdriver
driver = webdriver.Chrome()
try:
driver.get("https://www.example.com")
driver.save_screenshot("./image.png")
finally:
driver.quit()
The driver method writes the screenshot to the supplied path. To save only one element, locate it and call its screenshot method:
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
try:
driver.get("https://www.example.com")
element = driver.find_element(By.CSS_SELECTOR, "h1")
element.screenshot("./element.png")
finally:
driver.quit()
If you need image data rather than a file, Python also provides get_screenshot_as_png(), which returns PNG bytes. The Python API documents this alongside its screenshot methods: WebDriver Python API.
Java
Save the current browser screenshot
This example uses Selenium’s Java binding and Apache Commons IO to copy the returned temporary file to the desired path. Add Commons IO as a project dependency if using FileUtils.
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ScreenshotExample {
public static void main(String[] args) throws Exception {
WebDriver driver = new ChromeDriver();
try {
driver.get("https://www.example.com");
File screenshotFile = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshotFile, new File("./image.png"));
} finally {
driver.quit();
}
}
}
Capture one element
Locate a WebElement and request its screenshot file instead of calling the driver method:
Rank #3
WebElement element = driver.findElement(By.cssSelector("h1"));
File elementFile = element.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(elementFile, new File("./element.png"));
These Java calls follow Selenium’s documented screenshot examples at Working with windows and tabs.
C#
Save the current browser screenshot
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
var driver = new ChromeDriver();
try
{
driver.Navigate().GoToUrl("https://www.example.com");
Screenshot screenshot = (driver as ITakesScreenshot).GetScreenshot();
screenshot.SaveAsFile("screenshot.png", ScreenshotImageFormat.Png);
}
finally
{
driver.Quit();
}
Capture one element
Use the element’s screenshot interface for a targeted capture:
Rank #4
IWebElement element = driver.FindElement(By.CssSelector("h1"));
Screenshot screenshot = (element as ITakesScreenshot).GetScreenshot();
screenshot.SaveAsFile("element.png", ScreenshotImageFormat.Png);
The documented ScreenshotImageFormat values include BMP, GIF, JPEG, PNG, and TIFF. The example explicitly saves PNG. See Selenium’s language examples.
Capture content inside an iframe
WebDriver commands operate in the currently selected browsing context. To locate or capture iframe content, switch into the frame first. Selenium documents selecting a frame by its element, name or ID, or index; use the default-content switch to return to the top-level page.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsBest Value
- Used Book in Good Condition
// Java example: switch into a frame element, then back out
WebElement frame = driver.findElement(By.cssSelector("iframe"));
driver.switchTo().frame(frame);
WebElement framedElement = driver.findElement(By.cssSelector("h1"));
File image = framedElement.getScreenshotAs(OutputType.FILE);
driver.switchTo().defaultContent();
Adapt the frame-switching syntax to your binding. The key is to select the frame before issuing commands for its contents. See Selenium’s frame documentation.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.What Selenium returns
Selenium describes the WebDriver screenshot endpoint as returning screenshot data encoded in Base64. Language methods make that data easier to use: Python can write a file or return PNG bytes, Java can request a file with OutputType.FILE, and C# returns a Screenshot that can be saved with a chosen image format. The exact output and capture extent remain tied to the binding method and the browser driver.
Troubleshooting
- The screenshot is of the wrong page or tab: select the intended window or tab before capture. A driver screenshot applies to the current browsing context.
- An element inside an iframe cannot be found: switch into that frame before locating it; switch back to default content when finished.
- The output file is missing: check that the process can write to the chosen path and that its parent directory exists. Use an explicit path if the process working directory is not what you expect.
- The Java example does not compile at
FileUtils: Apache Commons IO is an additional dependency in that sample; add it or copy the screenshot file using another file-copy method. - The image does not include the whole page: do not infer full-page support from a driver screenshot call alone. Check the behavior documented for your browser and driver, or capture a specific element when that is what you need.
- The browser remains open after an error: put
quit()in afinallyblock as shown, so the session is closed even if navigation or saving fails.
Or skip the browser setup
ScreenshotNeo can return a screenshot or PDF through one GET request, without setting up a browser driver. Its cleanup accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. It also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://www.example.com -o shot.webp
See the ScreenshotNeo documentation for the API details. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. ScreenshotNeo is made by Yorker Media. Sign up for free.
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.




