Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Read the active page address with driver.current_url, then capture the current browser window with driver.save_screenshot("screenshot.png"). Selenium returns the URL and image through separate WebDriver operations, so save the URL in a log, test record, metadata field, or filename if it must travel with the image. The screenshot API documents the current browsing context/window; it does not promise to include browser chrome such as the address bar.

Minimal working example

This example navigates, reads the URL, saves a PNG immediately afterward, verifies that Selenium reported a successful write, and prints the URL associated with the file.

from selenium import webdriver

 driver = webdriver.Chrome()
try:
    driver.get("https://example.com")
    current_url = driver.current_url
    saved = driver.save_screenshot("screenshot.png")
    if not saved:
        raise OSError("Could not save screenshot.png")
    print(f"URL: {current_url}")
finally:
    driver.quit()

When copying the snippet, remove the extra leading space before driver = webdriver.Chrome() so it aligns with try::

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from selenium import webdriver

 driver = webdriver.Chrome()
try:
    driver.get("https://example.com")
    current_url = driver.current_url
    saved = driver.save_screenshot("screenshot.png")
    if not saved:
        raise OSError("Could not save screenshot.png")
    print(f"URL: {current_url}")
finally:
    driver.quit()

The second block above still shows the same indentation in the source formatting; the executable form is:

#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
from selenium import webdriver

driver = webdriver.Chrome()
try:
    driver.get("https://example.com")
    current_url = driver.current_url
    saved = driver.save_screenshot("screenshot.png")
    if not saved:
        raise OSError("Could not save screenshot.png")
    print(f"URL: {current_url}")
finally:
    driver.quit()

current_url is the URL Selenium reports for the current WebDriver page. save_screenshot() writes a PNG of the current window and returns a Boolean indicating whether Selenium saved it. See the Chromium WebDriver API and Python WebDriver API.

What “current URL” means in this workflow

It is the active WebDriver page address

Selenium reads the address of the page represented by the current driver window. If a click, form submission, redirect, or single-page application route change has completed, read driver.current_url after that transition to capture the resulting address.

The URL is not automatically printed on the image

The URL value and screenshot bytes are separate outputs. A normal Selenium screenshot is the page content in the current browsing context, not a guaranteed picture of the browser’s tab strip or address bar. If a human needs the address visible inside the image, put the URL into the page itself before capture or create a separate annotation; otherwise, keep it beside the PNG.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read and capture as one controlled operation

Read the URL immediately before saving the image. This minimizes the chance that a redirect or script navigation makes the text record refer to a different state. For pages that continue navigating, first wait for the application-specific condition that defines “ready,” then perform the two calls without allowing another navigation between them.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Keep the URL with the screenshot

Choose a storage format that matches your pipeline. The image file itself remains a PNG; the URL can be persisted separately.

Need Practical approach Result
Human-readable test artifact Print or log current_url beside the screenshot path A reviewer can match the record and image
Machine-readable report Write a JSON object containing the URL and filename CI systems can consume both values
Many captures in one folder Use a filesystem-safe URL-derived name plus a manifest Files remain distinguishable without losing the exact URL
Image-only handoff Render the URL into page content or an external annotation before capture The address is visible, but it is no longer supplied by Selenium’s browser chrome

Do not use an unescaped URL directly as a filename. Query strings, slashes, and characters forbidden by your operating system can make a write fail or cause collisions. A manifest retaining the exact URL is safer than trying to encode every character into a filename.

Example JSON record

import json
from selenium import webdriver

driver = webdriver.Chrome()
try:
    driver.get("https://example.com")
    current_url = driver.current_url
    image_path = "artifacts/example.png"
    if not driver.save_screenshot(image_path):
        raise OSError(f"Could not save {image_path}")
    with open("artifacts/example.json", "w", encoding="utf-8") as report:
        json.dump({"url": current_url, "screenshot": image_path}, report, indent=2)
finally:
    driver.quit()

Create the artifacts directory before running this example, or choose an existing writable directory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture after redirects, clicks, and dynamic rendering

After a navigation

driver.get() starts navigation, but the page may still change after the initial load. Use the wait condition appropriate to your application, such as the presence of a result element, then read current_url and save the image.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

After a click or form submission

A click can keep the same URL, produce a redirect, or update a single-page-app route. The correct sequence is: perform the action, wait for the state your test requires, read driver.current_url, and immediately call save_screenshot(). Do not assume that a changed visual state always implies a changed URL.

When the page can navigate again

If timers, links, or application code can trigger another navigation, take the URL and screenshot in a section of the test where those events are controlled. Otherwise, the URL may describe one state while the PNG depicts another.

Use screenshot bytes or Base64 instead of a file

The Python WebDriver API also exposes screenshot data when a file is not the right destination. Use get_screenshot_as_png() for PNG bytes or get_screenshot_as_base64() for a Base64 string, while still reading current_url separately.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from selenium import webdriver

driver = webdriver.Chrome()
try:
    driver.get("https://example.com")
    current_url = driver.current_url
    png_bytes = driver.get_screenshot_as_png()
    payload = {"url": current_url, "png": png_bytes}
    print(current_url, len(payload["png"]))
finally:
    driver.quit()

The bytes example keeps the image in memory; send or store them according to your application. The API reference documents the file, bytes, and Base64 forms at selenium.webdriver.common.webdriver.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

What Selenium captures—and what it does not promise

  • The documented scope is the current browsing context/window.
  • The PNG is not documented as including the browser’s address bar, tabs, or other interface chrome.
  • The URL is not embedded automatically as metadata by the two calls shown here.
  • Full-page behavior, viewport size, and dynamic content depend on the browser binding and page state; the basic call should be treated as a current-window capture.

Selenium’s browser-window guidance describes screenshot capture in the context of the current browsing context. Consult Working with windows and tabs when your test switches between windows or tabs: make sure the intended window is selected before reading the URL and taking the screenshot.

Common errors and fixes

“Could not save screenshot” or a false return value

  • Cause: The destination directory does not exist or is not writable.
  • Fix: Create the directory, use an absolute or known-writable path, and keep checking the Boolean returned by save_screenshot().

The URL and image do not match

  • Cause: A redirect, click handler, timer, or single-page-app navigation occurred between the URL read and the capture.
  • Fix: Wait for the intended state, prevent competing navigation, then perform both operations consecutively.

The address bar is missing

  • Cause: Selenium’s documented screenshot scope is the web page’s browsing context, not guaranteed browser chrome.
  • Fix: Store the URL beside the PNG, or render an address label in page content before capture if visual inclusion is required.

The screenshot shows an intermediate page

  • Cause: The capture ran before the application finished loading or rendering the element you need.
  • Fix: Add an application-specific wait for the required state, then read the URL and capture.

The wrong tab or window was captured

  • Cause: WebDriver was still focused on another browsing context.
  • Fix: Switch to the intended window or tab before reading current_url and calling save_screenshot(). The browser-window documentation covers window and tab handling.

The code fails before a screenshot is attempted

  • Cause: The browser driver cannot start, or the page navigation raises an exception.
  • Fix: Resolve the WebDriver/browser setup and navigation error first; retain driver.quit() in finally so failed runs clean up the browser.

Performance and reliability considerations

  • Save immediately after reading the URL when exact correspondence matters.
  • Wait for a meaningful application condition rather than adding an arbitrary delay; the right condition is page-specific.
  • Use deterministic, unique output paths in parallel or repeated runs to avoid overwriting artifacts.
  • Keep a structured record containing at least the exact URL and screenshot path.
  • Check the save result and handle file-system errors instead of treating a completed WebDriver call as proof that an artifact exists.
  • Use PNG bytes or Base64 when your next step uploads data directly and a temporary file adds no value.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

For a server-side capture, ScreenshotNeo returns an image or PDF from one GET request. Its cleaning steps accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed as clean shots, and the response identifies the page verdict and billing status with X-Page-Verdict and X-Billed headers. ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Use the URL you want to capture as the url parameter. The API documentation is at screenshotneo.com/docs/.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

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)

Node.js

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 supports PNG, JPEG, and WebP output; full-page capture with lazy images loaded; CSS-selector element capture; dark mode; 12 device presets plus custom viewports; retina scale; PDF paper size, margins, landscape, and page ranges; custom CSS and JavaScript; clicks; selector waits, delays, and network-idle waits; blocking for ads, trackers, requests, or resource types; custom headers, cookies, user agents, and Authorization; timezone and geolocation; transparent backgrounds; resizing; configurable-TTL caching; signed image links; asynchronous jobs with signed webhooks; bulk capture of up to 100 URLs per call; a usage API; and an OpenAPI specification. Parameter names used by other screenshot APIs also work for easier migration.

Plan Included shots Price
Free 1,000 per month $0, no card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Yearly billing gives two months free, and every feature is available on every plan. Start with 1,000 free screenshots a month with no card, or move to the $5 Starter plan for 3,000 shots.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Frequently asked questions

Can I retain the URL without saving an image file?

Yes. Read driver.current_url and store that string wherever your test report or application record belongs; screenshot creation is independent of URL persistence.

Which Selenium API should I use for an in-memory upload?

Use get_screenshot_as_png() for PNG bytes or get_screenshot_as_base64() for a Base64 representation instead of writing directly to disk.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is a screenshot filename a substitute for a URL record?

No. Filenames can be normalized, truncated, or made unique, while a separate manifest preserves the exact address Selenium returned.

Frequently Asked Questions

Does Selenium automatically add the page URL to PNG metadata?

No. The documented URL property and screenshot methods produce separate values; add your own manifest or annotation if that association matters.

Can ScreenshotNeo capture a PDF instead of an image?

Yes. Its API supports PDF output, including paper size, margins, landscape orientation, and page ranges.

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.

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.