Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk6 min

How to Screenshot a Login-Protected Website with Python Selenium

A practical Python Selenium workflow for signing into an authorized website, waiting for protected content, and saving a screenshot safely.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Selenium to sign in through the website’s normal login form, wait for a site-specific signal that authentication succeeded, open the protected page, and save the visible browser window with driver.save_screenshot("screenshot.png"). The login selectors and success condition depend on the site; Selenium cannot provide a universal recipe for them.

What you need before capturing

  • Python, Selenium, and a compatible browser and WebDriver setup. Selenium’s Python getting-started guide shows creating a Chrome driver and interacting with a page: Selenium WebDriver: Getting started.
  • The login URL, protected-page URL, and selectors for the login fields and a reliable authenticated-state marker. Find these for the site you are authorized to access; they are not universal.
  • A secure way to supply credentials at runtime, and a writable location for the screenshot.

The Python WebDriver API documentation identified in the available material is for Selenium 4.50.0. Browser, driver, and application behavior can vary, so check the current documentation for the versions in your own environment.

Log in, wait for the protected content, and save a screenshot

Use explicit waits for conditions that matter: first a marker that shows login succeeded, then the content you intend to capture. The selectors in this example are illustrative and must be replaced with selectors from the target site. This code has not been tested against a particular login page.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

# Supply these securely at runtime; do not commit credentials to source code.
username = ...
password = ...
login_url = "https://example.com/login"
target_url = "https://example.com/account/report"

 driver = webdriver.Chrome()
try:
    driver.get(login_url)
    wait = WebDriverWait(driver, 20)

    wait.until(
        EC.visibility_of_element_located((By.NAME, "username"))
    ).send_keys(username)
    driver.find_element(By.NAME, "password").send_keys(password)
    driver.find_element(By.CSS_SELECTOR, "button[type='submit']").click()

    # Replace with a site-specific element that proves login succeeded.
    wait.until(
        EC.visibility_of_element_located((By.CSS_SELECTOR, "[data-account-home]"))
    )

    driver.get(target_url)
    # Replace "main" if the target page has a more specific content selector.
    wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "main")))

    if not driver.save_screenshot("screenshot.png"):
        raise OSError("Could not write screenshot.png")
finally:
    driver.quit()

There is one formatting correction if copying the block: remove the leading space before driver = webdriver.Chrome() so the line starts at the left margin. The ... credential assignments and example URLs are deliberately not executable values; replace them with secure runtime values and the real URLs. Keep driver.quit() in finally so the browser is closed if login, waiting, or saving fails.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#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

Choose selectors and a success condition for the actual site

Use the site’s ordinary supported login flow and selectors that identify its real controls. A successful click is not proof of successful authentication: the site may reject credentials, redirect to an intermediate page, or request another supported step such as MFA. Wait for an element that appears only in the authenticated state, then wait for the target content.

Why an explicit wait matters

Selenium’s wait guidance explains that navigation waits for a configured document readyState—complete by default—but that does not guarantee JavaScript-driven application changes have finished. Waiting for the account marker and target content helps avoid racing ahead of the page. A fixed sleep can be both too short and unnecessarily long; a bounded condition-based wait gives a clearer failure when the expected state never appears. See Selenium: Waiting strategies.

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

What Selenium’s screenshot captures

driver.save_screenshot("screenshot.png") saves the current browser window as a PNG and returns a Boolean: True on success and False on an I/O error. Check the return value and use a path the process can write. The cited Python API does not promise that this method captures the entire document beyond the current window.

If you need image data rather than a file, Selenium’s Python API also documents get_screenshot_as_png() for PNG bytes and get_screenshot_as_base64() for a base64 string. For full-document output, support depends on browser and API: the Firefox Python API documents full-page methods such as save_full_page_screenshot. Verify support for the browser and driver you actually use rather than assuming the current-window method is full-page. See Selenium Python API documentation and Firefox WebDriver API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
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.

Reusing an existing session with cookies

WebDriver can add, retrieve, and manage cookies, but the browser must first be on a domain where a cookie is valid before adding it. Cookie scope, expiration, security settings, and the site’s authentication design can all affect whether reuse works; adding a cookie does not guarantee access. The API describes the mechanics, not the requirements of a specific site. See Selenium: Working with cookies.

Use cookie reuse only when permitted and when you understand the session requirements. Treat session-cookie values like credentials: do not commit, log, or share them, since they may grant account access.

Rank #4
Sale
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

Troubleshooting

  • The login-field wait times out: confirm the login URL, selector, and whether the controls are inside a frame or appear only after another page step. The example selectors are not universal.
  • The account marker never appears: check for rejected credentials, an unexpected redirect, or another step in the site’s supported authentication flow. Replace the example marker with one that uniquely indicates a signed-in state.
  • The target page is blank or incomplete in the image: wait for the actual content element, not just navigation or readyState. If content loads asynchronously, select a condition that reflects when it is visible.
  • save_screenshot returns False or raises an I/O error: check that the output path exists and is writable by the process, and that the filename is valid for the environment.
  • The screenshot omits content below the visible window: save_screenshot captures the current window; use a full-page method supported by your browser/API or capture the page in sections.
  • Cookie-based login does not work: verify domain and cookie validity, and account for expiration or additional checks. A cookie alone may not satisfy the site’s authentication flow.
  • The browser behaves differently in another environment: browser, driver, Selenium version, headless/display setup, and site behavior can affect results. Check the current browser-specific documentation and reproduce the issue with the versions you deploy.

Security and reliability notes

  • Automate only accounts and content you are authorized to access, and follow the target site’s applicable rules.
  • Keep passwords and session cookies out of source control and logs. Store the resulting image securely too; screenshots can expose personal, confidential, or regulated information.
  • Use bounded waits and meaningful errors so a login failure is distinguishable from a file-writing failure.
  • Do not assume a successful navigation means the user is authenticated, or that a viewport screenshot contains the full page.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. For a public target URL, one GET request returns a PNG, JPEG, WebP, or PDF. It is not a substitute for Selenium when you need to sign into a protected site using that site’s account flow; the example below uses a public URL.

cURL example; replace the target URL as needed. See the ScreenshotNeo documentation for API options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of these steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and each response indicates the page verdict and billing status in headers. 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 with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Frequently Asked Questions

Can Selenium screenshot a page after login?

Yes. Once Selenium has authenticated and the target content is visible, driver.save_screenshot() saves the current browser window as a PNG.

Does save_screenshot capture the whole webpage?

It captures the current browser window; full-document capture depends on browser-specific support.

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.