Free tools Windows power users keep installed
One-click scans. No signup required.
To convert HTML into an image with Python and Selenium, open the HTML in a browser controlled by WebDriver and save a screenshot. For a local page, navigate to its file URL; for a hosted page, navigate to its web URL. Selenium’s standard screenshot methods capture the current browser window as a PNG.
Convert a local HTML file to a PNG
Install Selenium, save your markup as page.html, then run this script from a Python environment with a supported browser available:
from pathlib import Path
from selenium import webdriver
html_path = Path("page.html").resolve()
output_path = Path("output.png").resolve()
driver = webdriver.Chrome()
try:
driver.get(html_path.as_uri())
saved = driver.save_screenshot(str(output_path))
if not saved:
raise OSError(f"Could not save screenshot: {output_path}")
finally:
driver.quit()
Path.resolve() makes the paths absolute, and as_uri() produces a local file: URL for navigation. The output is written to output.png in the current working directory. This captures the current browser window, not necessarily the entire document.
Install and start Selenium
-
Install the current Selenium Python package with
python -m pip install -U selenium. The Selenium Python documentation currently lists Python 3.10 or newer as supported; check the official Selenium documentation for current requirements and browser support.Outdated 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 matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Install or make available a supported browser such as Chrome, Edge, Firefox, or Safari. Selenium requires a browser driver. In modern supported setups, Selenium Manager can handle browser-driver installation and configuration when you instantiate WebDriver; manual setup may still be needed in constrained environments.
-
Run the script in an environment where the browser can start. A local Selenium script does not need the Java server; remote WebDriver execution requires Selenium Grid.
For code that writes screenshots to memory instead of a file, Selenium’s Python WebDriver API also provides get_screenshot_as_png(). The API documents save_screenshot(filename) and get_screenshot_as_file(filename) for file output, and base64 methods for embedding. See the Python WebDriver API reference.
Capture a remote page or set a precise viewport
For a remote page, navigate to its URL rather than a local file URI. If the dimensions matter, explicitly size the browser window before capture:
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Rank #2
driver.set_window_size(1280, 900)
driver.get("https://example.com")
driver.save_screenshot("output.png")
Set the size before capture (and, where practical, before navigation) to make the browser viewport predictable. Actual output can still depend on browser chrome, scrollbars, page zoom, device scale, fonts, and when images or scripts finish loading. Verify dimensions and rendering in the same browser and runtime you intend to use.
Choose viewport, element, or full-page capture
Current window
save_screenshot() captures the current browser window. Use it when the image should show the visible viewport at the current scroll position.
One element
When the goal is a component—such as a card or chart—rather than the viewport, locate the element and use Selenium’s element screenshot method. Selenium documents element screenshot capture in its WebDriver documentation. This avoids cropping a larger page image by hand, though the element must be present and visible to capture.
Entire document
Full-document capture is not a universal cross-driver promise. The Firefox Python API documents driver.get_full_page_screenshot_as_file(path) and driver.save_full_page_screenshot(path). Check the API for your selected browser driver and test the result against your target browser version; do not assume those Firefox-specific methods work with Chrome or every WebDriver implementation. See the Python API reference.
Recommended Free Tools
Wait for dynamic content before taking the screenshot
A screenshot records the browser’s rendered state at capture time. If JavaScript is still populating the page, fonts have not loaded, or images are still appearing, the saved image may be incomplete. Prefer waiting for a meaningful page element or an application-ready condition over relying only on an arbitrary fixed delay. Then take the screenshot. Selenium’s screenshot methods do not themselves guarantee that a site’s asynchronous content is ready.
For stable visual output, also check that required assets are accessible from the browser, that the page has the expected viewport and scroll position, and that any lazy-loaded content has actually been triggered. A full-page method and a viewport method may behave differently with content loaded only after scrolling.
Check the result and close the browser reliably
The file-saving screenshot methods return a boolean. Check it and raise a clear error if saving fails, as the example does. Use an absolute output path when the script may be launched from different working directories. Put driver.quit() in a finally block so the browser session is closed even when navigation or capture raises an exception.
Troubleshooting
-
WebDriver fails to start: Confirm that a supported browser is installed and usable in the runtime. Selenium Manager handles driver setup in many modern supported environments, but locked-down networks, permissions, or unusual installations can require manual browser-driver configuration. Consult the current Selenium setup documentation.
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. -
The screenshot is blank or missing page content: Check that navigation completed to the intended file or URL, that local assets resolve correctly, and that the page’s scripts have reached the state you need before capture. Wait for an application-ready element rather than capturing immediately.
-
The output has the wrong dimensions: Set an explicit window size and confirm whether you need the viewport or the entire document. Scrollbars, zoom, browser behavior, and device scale can affect the final image.
-
The screenshot file is not where expected: Resolve the output path and inspect it in the script, or use an absolute path. Check the return value from
save_screenshot()and ensure the destination is writable. -
The browser stays open after an error: Ensure the capture code is wrapped in
try/finallyand thatdriver.quit()runs in thefinallyblock.Recommended: Fix Windows Errors and Clear Junk Files in Minutes - Free Scan →Recommended: Update Every Outdated Driver on Your PC in One Scan - Free →Recommended: PC Feels Slow? A Free Scan Shows What's Dragging Windows Down →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
A full-page method is unavailable: Confirm the browser driver and its API. The documented full-document methods cited above are Firefox-specific, not a guarantee for every driver.
Or skip the browser setup
If you want an API call instead of managing WebDriver, ScreenshotNeo returns a screenshot or PDF from one GET request. For example, this saves a WebP capture of a page:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for API details. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. It also offers an MCP server for AI agents, and includes 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000. Sign up for the free plan.
When Playwright may fit better
If your project is not committed to Selenium, Playwright is another documented Python option. Its library guide covers Chromium, Firefox, and WebKit, and its screenshot guide uses page.screenshot(path="screenshot.png"); browsers run headless by default. The documentation establishes these capabilities, not a general performance or image-fidelity advantage over Selenium. Choose based on the browser behavior, capture scope, and automation library your project needs. See the Playwright library guide and screenshot guide.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Frequently Asked Questions
Can Selenium save a screenshot as JPEG or WebP?
The Selenium file-saving methods described here save PNG screenshots. The ScreenshotNeo example in this article returns WebP by default.
Does taking a Selenium screenshot require Java?
Not for a local Selenium script. Remote WebDriver execution uses Selenium Grid.
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.




