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.

driver.save_screenshot("page.png") captures the current page in Selenium’s browsing context; it does not promise to include the browser’s tabs, toolbar, or address bar. To show the URL bar in the image, use Selenium to open the page and then capture the visible browser window or desktop with a screen-capture library such as PyAutoGUI or Pillow ImageGrab.

Choose the capture target first: page viewport, visible browser frame with URL, entire scrollable document, or a particular page element. They are different outputs and need different methods.

What Selenium’s screenshot includes—and what it does not

Selenium’s WebDriver screenshot methods capture the current browsing context. In Python, driver.save_screenshot(path) writes a PNG of the current window, and driver.get_screenshot_as_file(filename) is another documented option. The API does not promise a capture of the browser’s own interface, so do not rely on either method to show the address bar. See the Selenium Python WebDriver API and Selenium’s WebDriver documentation.

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

A full-page capture is different again: it covers the scrollable webpage rather than browser chrome. Likewise, an element screenshot isolates page content. Neither means the address bar is included.

What you need Method Key limitation
Visible page viewport Selenium driver.save_screenshot() Does not promise browser chrome.
Browser frame and visible URL bar Selenium navigation plus desktop or window capture Requires a visible graphical browser; focus and screen contents affect the image.
Entire scrollable page A browser API with an explicit full-page option Captures document content, not the browser interface.
One page element WebDriver element screenshot or a locator screenshot Captures the element, not the browser interface.

Capture the visible URL bar with Selenium and PyAutoGUI

This approach uses Selenium to navigate and PyAutoGUI to capture what is visibly on screen. It is suitable when the URL bar itself must appear in the evidence image. The browser must run in a graphical desktop session and be in the foreground; a headless browser has no visible address bar to capture.

  1. Install Selenium and PyAutoGUI: python -m pip install selenium pyautogui. PyAutoGUI’s screenshot feature also requires Pillow; its documentation describes operating-system-specific dependencies, including scrot for Linux in that documentation. Check the PyAutoGUI screenshot documentation for your platform.

  2. Save the following as capture_browser.py, replacing the example URL with the target. Ensure the browser can open visibly on the machine running the script.

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

with webdriver.Chrome() as driver:
    driver.get("https://example.com")
    driver.maximize_window()
    time.sleep(1)  # Simple settling delay; use a real page condition for robust automation.
    pyautogui.screenshot("browser-with-url.png")
  1. Run python capture_browser.py. The output is saved as browser-with-url.png in the current working directory. Inspect it to confirm the browser frame and intended URL are visible.

The one-second pause is only a simple example, not a reliable readiness test. For production use, wait for the page condition you need—such as a known element—and verify that the intended browser window is foregrounded immediately before capture. A desktop screenshot records visible screen pixels, so another window covering Chrome can appear in the image.

Capture only a stable screen region

PyAutoGUI accepts a region in the form (left, top, width, height). Use it only when the browser’s position and size are stable:

pyautogui.screenshot("browser-region.png", region=(100, 80, 1200, 800))

Coordinates can break when display scaling, monitor arrangement, window placement, or resolution changes. If you need a window-only image rather than a screen region, Pillow ImageGrab documents a bounding box and single-window capture support on Windows and macOS. Its Linux behavior depends on the display environment and available fallbacks. Consult the Pillow ImageGrab reference and verify support on the operating system and display server you actually use.

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

Capture page content only with Selenium

If the URL bar is not part of the required image, Selenium’s built-in screenshot method is simpler and does not depend on capturing the desktop. This runnable example checks the API’s return value so a failed write is not silently treated as success:

from pathlib import Path
from selenium import webdriver

output = Path("page.png")
output.parent.mkdir(parents=True, exist_ok=True)

with webdriver.Chrome() as driver:
    driver.get("https://example.com")
    saved = driver.save_screenshot(str(output))
    if not saved:
        raise OSError(f"Could not save screenshot to {output.resolve()}")

print(f"Saved {output.resolve()}")

Selenium documents the output as PNG; use a .png filename. A valid destination directory matters: the method returns False if an I/O error occurs. This image is of the WebDriver browsing context, not proof that the browser toolbar or URL bar was captured.

Choose full-page or element capture when that is the real goal

Sometimes “screenshot with URL” gets conflated with “full-page screenshot.” A full-page result includes the scrollable website content, while the URL bar is browser chrome. For a full-page capture, use an API that explicitly supports that scope. Playwright’s Python documentation describes full_page=True and locator screenshots; these capture webpage content, not the outer browser interface. See Playwright’s screenshot documentation.

For an element-specific result, Selenium’s WebElement screenshot capability can save the target element rather than the complete viewport. That is useful for a chart, card, or component, but it does not include browser chrome.

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

Make the capture reliable and safe

Or skip the browser setup

If you need page screenshots without managing a visible desktop browser, ScreenshotNeo is a website screenshot API and MCP server. One GET request can return an image or PDF; its API options also include full-page capture, element selection, device and viewport settings, and PDF controls. See the ScreenshotNeo API documentation.

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

ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month, with no card required.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The screenshot has no address bar

You used a WebDriver page screenshot, which captures the browsing context rather than promising browser chrome. Use Selenium for navigation and PyAutoGUI or an appropriate ImageGrab/window capture method for visible screen pixels.

The image shows the wrong window or other desktop content

A desktop screenshot captures what is visible, not necessarily the browser Selenium controls. Bring the intended browser window to the foreground, make sure it is not obscured, and avoid relying on whole-screen capture if unrelated applications are open. For a stable setup, capture a defined region or use a suitable platform window-capture facility.

The output file is missing or empty

Check that the destination directory exists and that the process can write there. For Selenium, check the boolean result from save_screenshot() and use a PNG filename. For PyAutoGUI, confirm the required imaging dependency is installed and that the platform supports its screenshot operation.

The script works locally but fails on Linux or a server

Determine whether the process has access to a graphical display session. Desktop screenshot methods depend on the OS and display server; PyAutoGUI’s documentation notes an OS-specific Linux dependency, and Pillow describes Linux/display-server fallbacks. A headless server cannot show a browser address bar unless a visible desktop session is provided.

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 catches a loading state

Replace the arbitrary sleep with an explicit wait for the page condition that matters. For desktop capture, also ensure the browser is foregrounded and settled when the image is taken.

The URL bar is visible but does not show the intended address

Verify the active tab and current navigation in the visible browser before capture. The screen capture records pixels; it does not validate that the visible URL matches the page you meant Selenium to open.

Performance, reliability, and cost considerations

A WebDriver page screenshot avoids capturing unrelated desktop pixels, but it cannot meet a requirement to show browser chrome based on the documented screenshot behavior. Desktop capture adds dependence on a GUI, window focus, display permissions, and screen geometry. These are operational requirements, not extra Selenium settings.

For repeatable automated evidence, choose a fixed viewport and desktop layout, wait on explicit page conditions, and inspect output images in the environment where the job will run. For remote or batch capture where maintaining a GUI is inconvenient, a screenshot API can handle rendering outside your local desktop. ScreenshotNeo’s listed plans range from its free allowance to paid tiers, and only clean shots are billed; consult its own documentation for request parameters and response headers.

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

Frequently Asked Questions

Does Selenium’s `save_screenshot()` include the browser address bar?

It captures the current WebDriver browsing context and does not promise browser chrome. Use a visible desktop or window capture when the URL bar must appear.

Can I capture the URL bar in headless Chrome?

Not as visible screen content: headless execution has no on-screen browser frame. Use a graphical browser session for a browser-frame image.

Does a full-page screenshot show the URL bar?

No. Full-page capture refers to the webpage document, not the browser interface.

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.

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