Free tools Windows power users keep installed
One-click scans. No signup required.
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
To capture page state and a screenshot together, save the rendered image and the page data as separate artifacts: in Selenium, read driver.page_source, evaluate any JavaScript-derived values you need, and call driver.save_screenshot(). PhantomJS can do a similar job with page.content, page.evaluate(), and page.render(), but PhantomJS and Selenium are separate capture approaches—not one combined browser stack. For a full-page Selenium screenshot, use a driver API that supports it, such as Firefox’s save_full_page_screenshot(); ordinary save_screenshot() captures the current window.
What “page state” means—and what a screenshot misses
A screenshot records pixels, not the underlying page data. It can show what the browser rendered at a moment in time, but it does not preserve the DOM as structured data or explain whether a capture followed a successful page load.
For a useful record, save at least two things:
- Rendered output: a PNG or other supported image of the viewport or chosen region.
- Page state: the main-frame HTML, plus evaluated values such as the title, visible text, or application-specific data.
HTML and evaluated values are complementary. HTML provides the main-frame markup exposed by the browser; JavaScript evaluation can return values computed after scripts have run. Neither guarantees a complete record of every browser detail, such as network activity or state inside every frame. Choose the fields that answer the debugging or archival question you actually have.
Capture page state and a screenshot with Selenium
The following Python example navigates with Selenium, reads the current page source, evaluates the document title and visible body text, writes the viewport screenshot, and stores the captured state as JSON. It assumes Selenium and a compatible Firefox WebDriver setup are already available in the environment; driver installation and version-management procedures are environment-specific.
#1 Best Overall
import json
from selenium import webdriver
url = "https://example.com"
driver = webdriver.Firefox()
try:
driver.get(url)
html = driver.page_source
state = driver.execute_script("""
return {
title: document.title,
text: document.body ? document.body.innerText : ""
};
""")
screenshot_saved = driver.save_screenshot("capture.png")
with open("page.html", "w", encoding="utf-8") as f:
f.write(html)
with open("state.json", "w", encoding="utf-8") as f:
json.dump(state, f, ensure_ascii=False, indent=2)
if not screenshot_saved:
raise RuntimeError("Selenium did not save capture.png")
finally:
driver.quit()
Replace https://example.com with the target URL. The script produces capture.png, page.html, and state.json in the current working directory. The screenshot API writes a PNG of the current window; it does not turn the HTML or JSON into part of the image.
Wait for the state you need
driver.get(url) navigates to the URL, but a page may continue changing after navigation returns—for example, client-side code may fetch data or reveal content later. If the target state depends on a specific element or application condition, wait for that condition before reading HTML or taking the screenshot. The appropriate condition is application-specific; do not assume a fixed delay makes a dynamic page ready.
Save a screenshot as Base64 when needed
If the next step needs an embeddable string rather than a file, Selenium exposes get_screenshot_as_base64(). For example:
png_base64 = driver.get_screenshot_as_base64()
Keep the format distinction clear: Selenium documents save_screenshot() as saving the current window to a PNG file, while Base64 returns an encoded representation for embedding or transport. The caller is responsible for storing or embedding that returned string.
Capture the same kinds of artifacts with PhantomJS
PhantomJS uses its own page API rather than Selenium’s Python WebDriver methods. Its documented pattern is to open a URL, check the callback status, collect HTML and evaluated values, then render the page.
Rank #2
var page = require('webpage').create();
var url = 'https://example.com';
page.viewportSize = { width: 1280, height: 900 };
page.open(url, function (status) {
if (status !== 'success') {
console.error('Page open failed: ' + status);
phantom.exit(1);
return;
}
var html = page.content;
var state = page.evaluate(function () {
return {
title: document.title,
text: document.body ? document.body.innerText : ''
};
});
require('fs').write('page.html', html, 'w');
require('fs').write('state.json', JSON.stringify(state, null, 2), 'w');
page.render('capture.png');
phantom.exit();
});
The callback status is an important gate: PhantomJS documents that page.open(url, callback) reports success or fail. This example exits with a nonzero status on failure rather than silently producing artifacts from an unsuccessful open. The file names and JSON schema are implementation choices.
Set viewport and clip geometry deliberately
PhantomJS documents viewportSize for the browser viewport and clipRect for the region to render. In the example, the viewport is set before navigation so the rendering geometry is explicit. To constrain the rendered region, set a rectangle before calling page.render(), for example:
Recommended Free Tools
page.clipRect = { top: 0, left: 0, width: 800, height: 600 };
A viewport describes the browser’s viewing area; a clip rectangle selects a render region. They are not substitutes for saving page state, and they do not by themselves establish that the entire document has been captured.
Choose a PhantomJS output format
PhantomJS documents page.render() output support for PNG, JPEG, GIF, and PDF. The output format is determined by the render target and filename; use the format appropriate to the consumer. A PDF is a document output, not an HTML or machine-readable state record.
How to get a full-page screenshot
Do not assume a normal screenshot includes the entire document. Selenium’s ordinary save_screenshot() captures the current window. Selenium’s Firefox API separately documents save_full_page_screenshot() for full-page capture:
driver.save_full_page_screenshot("full-page.png")
This is a Firefox-specific API documented by Selenium, so check that the WebDriver in your runtime exposes it before relying on it. Full-page support is driver-specific; the ordinary current-window call and the Firefox full-page call are not interchangeable.
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 →For PhantomJS, configure rendering geometry with viewportSize and, when needed, clipRect. If your requirement is specifically a full document, verify the behavior against the exact PhantomJS version and page you run; the documented viewport and clip controls alone are not a blanket guarantee of full-document capture.
Choose the right capture pattern
| Need | Use | What it gives you |
|---|---|---|
| Current-window image in Selenium | save_screenshot() |
PNG screenshot of the current window. |
| Image data to embed or pass onward | get_screenshot_as_base64() |
Base64 screenshot data. |
| Full-page screenshot in Selenium | Firefox API save_full_page_screenshot() |
Full-page capture through the documented Firefox API; driver-specific availability applies. |
| Main-frame markup | Selenium page_source or PhantomJS page.content |
HTML source exposed for the page’s main frame. |
| Computed values after scripts run | Selenium execute_script() or PhantomJS page.evaluate() |
Values returned by JavaScript executed in the page. |
| PhantomJS image or PDF render | page.render() |
PNG, JPEG, GIF, or PDF output, with geometry controlled using documented page settings. |
Use Selenium when your existing automation is built around WebDriver and its browser/driver environment. Use PhantomJS page APIs only in a runtime where PhantomJS itself is available and suitable. These snippets illustrate the respective APIs; they do not imply that one should be called from the other.
Troubleshoot missing, incomplete, or misleading captures
The screenshot exists but page data is empty
Check whether the page has finished producing the data you intend to record. A successful navigation does not necessarily mean a client-rendered application has reached its final state. Wait for an application-specific element or condition, then capture both the screenshot and state from the same browser session.
PhantomJS reports a failed open
Check the URL and the page-open callback status. The documented callback distinguishes success from fail; branch on that result before reading page.content or rendering. Preserve the process exit code or log so an automation job can detect the failed run.
PC 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 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteThe screenshot shows only part of the page
In Selenium, confirm whether you used the current-window method or Firefox’s documented full-page method. In PhantomJS, inspect the configured viewportSize and clipRect. These settings determine viewing or clipping geometry, not whether a page’s delayed content has loaded.
The screenshot is blank or the visible text differs from expectations
Compare the image with the saved HTML and evaluated values. If the page’s markup or returned values are also missing, investigate navigation and application readiness first. If the state looks right but the image does not, inspect the viewport and clip settings and make sure the render occurs after the intended page state is reached.
The full-page method is unavailable
save_full_page_screenshot() is documented for Selenium’s Firefox API, not as a universal WebDriver method. Use a supported Firefox setup for that API or choose a capture approach that explicitly supports the page scope you require; do not treat save_screenshot() as a fallback full-page operation.
Performance, reliability, and reproducibility
The official API material cited here does not establish comparative speed or resource-use benchmarks, so there is no defensible universal claim that PhantomJS or Selenium is faster for this task. Runtime performance depends on the page, browser and driver versions, readiness condition, output size, and execution environment.
For reliable debugging, preserve the artifacts from the same run and give them a shared identifier: image, HTML, evaluated state, requested URL, timestamp, and success/failure status. Record the browser and driver versions in your own job logs. The PhantomJS callback provides an explicit page-open status; Selenium workflows should likewise make navigation or application-readiness failures visible rather than treating the mere existence of a screenshot as proof of success.
Best Value
Or skip the browser setup
If you need a screenshot without managing a browser and driver, ScreenshotNeo is a website screenshot API and MCP server. Its API accepts a URL and returns an image or PDF; it can also remove cookie and consent banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, and failed loads are not billed, and its responses identify page verdict and billing status. An MCP server exposes screenshot tools for AI agents.
Here is a cURL request using the documented endpoint and parameter pattern; replace the example URL and API key with your own. See the ScreenshotNeo API documentation for options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo includes 1,000 screenshots per month on its free plan with no card required; paid plans start at $5 for 3,000. For this route, the returned capture is the screenshot or PDF response, not a Selenium page-source dump, so retain browser-side HTML and evaluated state when those are required for your task.
Sign up free for 1,000 screenshots a month, with no card required.
Frequently Asked Questions
Can Selenium save both the screenshot and the page HTML in one call?
No. Capture them as separate outputs from the same driver session: use page_source for HTML and a screenshot method for pixels.
Does a screenshot include JavaScript variables or application state?
No. Use page JavaScript evaluation to return the specific computed values you need, and save them alongside the image.
Is PhantomJS the same thing as Selenium?
No. PhantomJS’s page API and Selenium’s WebDriver API are separate capture approaches.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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.

