Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk6 min

How to Take a Screenshot of a Login-Protected Webpage with Selenium

A dependable Selenium workflow for authorized login, page-specific waits, and screenshots of protected webpages.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Selenium to establish an authorized session, open the protected page, wait for a page-specific sign that it has finished rendering, and then save a screenshot. For repeatable tests, Selenium recommends establishing application state by another supported method—such as an API login followed by setting a session cookie—instead of repeating login-form interactions when those interactions are not what you need to test. If you need to test the login experience itself, use the site’s normal authorized login flow.

Choose how to authenticate

The right setup depends on what the screenshot is meant to verify. Use the real login flow when the login process is part of the test. If the test only needs an authenticated starting state, an application-supported API login and session cookie can avoid repeating browser steps. Selenium’s guidance on generating application state describes the latter approach: Selenium: Generating application state.

As an Amazon Associate I earn from qualifying purchases.

  • Normal login flow: exercises the site’s actual login page and interactions, but may add steps unrelated to the page being captured.
  • API plus cookie: can establish a repeatable authenticated starting state, but depends on the application’s supported authentication mechanism and cookie requirements.

Only use credentials and sessions you are authorized to access. Cookie names, values, domains, expiry, and any additional server-side state are application-specific; there is no universal cookie recipe.

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

Take a screenshot after login with Python

Install Selenium and configure a compatible browser and WebDriver for your environment. The example below uses Chrome, then waits for an element that should only appear on the authenticated page. Replace the URLs, credentials or login steps, selector, and timeout with values appropriate to your application; the example selector and timeout are illustrative, not tested against a live site.

#1 Best Overall
HP OmniBook 3 17.3 inch Laptop PC, FHD Display, AMD Ryzen 3 30, 8 GB RAM, 512 GB SSD, AMD Radeon 610M Graphics, Windows 11 Home, Mica Silver, 17-dp0199nr
  • FULL HD IPS DISPLAY - Enjoy vibrant, crystal-clear images with 178-degree wide-viewing angles
  • AMD RYZEN 3 30 PROCESSOR - Everyday performance you can count on; Multitask, stream, game casually, and edit photos smoothly with responsive power and vibrant HDR visuals
  • ENJOY UP TO 14 HOURS AND 15 MINUTES OF BATTERY LIFE - HP Fast Charge restores battery from 0 to 50% in approximately 45 minutes
  • AMD RADEON 610M GRAPHICS - Experience smooth entertainment; Built for streaming and multitasking, enjoy realistic visuals and efficient performance for work and play
  • STORAGE AND MEMORY - 512 GB PCIe NVMe M.2 SSD offers fast speed and efficient storage; and 8 GB LPDDR5 RAM memory boosts performance with higher bandwidth
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

 driver = webdriver.Chrome()
try:
    driver.get("https://example.test/login")
    # Complete the site's authorized login flow here.
    # Alternatively, establish an approved session and add its cookie
    # after first visiting a page on the cookie's valid domain.
    driver.get("https://example.test/protected/page")
    WebDriverWait(driver, 10).until(
        EC.visibility_of_element_located(
            (By.CSS_SELECTOR, "[data-testid='account-home']")
        )
    )
    driver.save_screenshot("page.png")
finally:
    driver.quit()

Remove the leading space before driver = webdriver.Chrome() in the code above so it aligns with try. The correctly aligned, runnable version is:

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

driver = webdriver.Chrome()
try:
    driver.get("https://example.test/login")
    # Complete the site's authorized login flow here.
    # Or establish an approved session and add its cookie on the right domain.
    driver.get("https://example.test/protected/page")
    WebDriverWait(driver, 10).until(
        EC.visibility_of_element_located(
            (By.CSS_SELECTOR, "[data-testid='account-home']")
        )
    )
    driver.save_screenshot("page.png")
finally:
    driver.quit()

save_screenshot("page.png") saves a PNG of the current browser window. The sample does not implement a site’s login form or API authentication: those steps must match the target site’s authorized process. See the Selenium Python Chrome WebDriver API for the screenshot method.

Rank #2
HP 14" HD Chromebook Laptop for Students, Intel Quad-Core N4120(> N4020), 4GB RAM, 64GB eMMC, WiFi, Webcam, HDMI, USB-A&C, 14 Hours Battery Life, Zoom, Chrome OS, CUE Accessories
  • Intel Celeron N4120: 4 Cores & Threads, 1.1GHz Base Clock, Up to 2.6GHz Boost Clock, 4MB Cache, Intel UHD Graphics 600. The perfect combination of performance, power consumption, and value helps your device handle multitasking smoothly and reliably with four processing cores to divide up the work.

Set a cookie only after visiting its domain

When using an approved API-created session, WebDriver must first be on a page within the cookie’s valid domain before adding it. For example, navigate to an appropriate lightweight page on the same site, add the application-specific cookie, and then open the protected URL. Consult the application’s documentation for the correct cookie attributes and any other authentication state it requires. Selenium documents cookie operations in its WebDriver cookie guide.

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

Do not assume that one cookie will work for every application: a session can depend on domain and path scope, expiry, server-side state, or additional authentication checks. If the application cannot safely reuse a cookie or needs the real browser login flow, use that normal flow instead.

Rank #3
Sale
AKCHART 15.6'' AI Laptop with Office 365 12GB RAM 256GB SSD Win 11 Laptops | 7000mAh Battery, IPS FHD, 180°Viewing, Quad-Core Processor, Type-C, WiFi5, Portable Thin Business Student Laptops, Light Gray
  • Stunning 15.6" FHD IPS Display: Experience crisp 1920x1080 resolution on this 15.6 inch laptop with an IPS panel that delivers wide viewing angles and vivid colors. The narrow-bezel design maximizes screen real estate for comfortable viewing on this Win 11 laptop, whether you're studying or working.
  • Celeron J4105 Processor & 256GB SSD: Powered by a reliable Celeron J4105 processor paired with 12GB DDR4 memory and a fast 256GB M.2 SSD. This laptop computer supports SSD expansion up to 2TB and TF card expansion up to 1TB, so your storage grows with your needs. Delivers smooth multitasking for daily productivity.
  • AI-Powered Win 11 Laptop: Built-in AI features enhance your productivity with smart assistance for writing, summarizing, and task management. Pre-installed with Win 11 and includes Office 365 subscription. This student laptop is backed by 1-year warranty and 24/7 customer support.
  • All-Day 7000mAh Battery & 180° Hinge: The high-capacity 7000mAh battery keeps this laptop powered through long classes or meetings. The 180-degree lay-flat hinge lets you share your screen effortlessly during presentations. This durable laptop computer adapts to your dynamic workflow.
  • Versatile Connectivity Hub: Equipped with USB 3.2, Type-C, Mini HDMI, and 3.5mm audio jack to connect all your peripherals. Stay online anywhere with high-speed 5G WiFi and Bluetooth 4.2. This college laptop keeps you connected at home, in the library, or on the go.

Wait for the authenticated page, not just navigation

A completed navigation does not guarantee that a JavaScript-driven page has finished drawing its useful content. WebDriver’s page-load strategy waits for a document readiness state, but scripts may continue updating the page afterward. Use an explicit wait for a meaningful condition, such as visibility of a unique account or page element. If appropriate, also check that a known login form or redirect is absent. Selectors must be chosen for the actual site; no universal authenticated-page selector exists.

Use explicit waits for the condition the screenshot requires. Selenium cautions that mixing implicit and explicit waits can produce unpredictable wait times; see Selenium waiting strategies.

Rank #4
HP Essential Laptop 2026, Intel CPU, 128GB Storage, Office 365, Windows 11 | Copilot AI, WiFi 6, Long Battery Life, Lightweight & Portable, Online Learning, Browsing, Streaming, Willow Green
  • Efficient Performance for Everyday Computing: Powered by Intel N150 processor with up to 3.6 GHz Intel Turbo Boost Technology, 6 MB L3 cache, 4 cores, and 4 threads, this HP laptop delivers responsive performance for web browsing, streaming, document editing, and multitasking. Paired with 4GB LPDDR5 RAM and 128GB UFS storage, it handles daily tasks smoothly. Includes 1-year Microsoft 365 Personal subscription for Word, Excel, PowerPoint, and cloud storage to maximize your productivity.
  • 14-Inch HD Micro-Edge Display:Enjoy clear visuals on the 14-inch HD (1366 x 768) anti-glare screen with 250-nit brightness and 62.5% sRGB coverage. The micro-edge bezel delivers a 79% screen-to-body ratio in a compact design. An HP True Vision 720p HD camera with noise reduction and dual-array microphones supports clear video calls, remote work, and online learning.
  • Modern Connectivity and Wireless Technology: Stay connected with Wi-Fi 6 (2x2) for faster wireless speeds and Bluetooth 5.4 for seamless pairing with accessories. Versatile port selection includes 1 USB Type-C 10Gbps with DisplayPort 1.2 for external displays, 2 USB Type-A 5Gbps ports for peripherals, 1 HDMI 1.4b port, 1 headphone/microphone combo jack, and 1 multi-format SD media card reader. Connect monitors, transfer files quickly, and expand your workspace with ease.
  • All-Day Battery Life and Portable Design: Enjoy up to 11 hours of video playback, 7.5 hours of mixed usage, or 7.5 hours of wireless streaming on a single charge, perfect for students and professionals on the go. Weighing just 3.24 lb and measuring 12.76" x 8.86" x 0.71", this lightweight laptop fits easily in backpacks and bags. The stylish willow green top cover with matte finish and natural silver keyboard deck with vertical brushing pattern offer a modern, professional look.
  • AI-Enhanced Productivity: Access Microsoft Copilot instantly with the dedicated Copilot key for faster assistance. AI Noise Reduction filters background sounds and improves voice clarity during calls. Dual speakers provide clear audio, while the full-size natural silver keyboard and HP Imagepad support comfortable typing and navigation.

Choose the screenshot area

Capture method What it captures When to use it
Driver/page screenshot The current browser window’s visible view. Use it when the viewport is the required evidence or image.
Element screenshot The visible region encompassed by the selected element. Use it when you need one visible component rather than the whole current view.
Full-page screenshot The entire scrollable document, if supported by the browser, driver, and Selenium binding in use. Verify support for your specific setup before relying on it; full-page behavior is not uniform across bindings and drivers.

For an element capture in Python, locate the element after the page-specific wait and call its screenshot method, for example element.screenshot("component.png"). The result covers the element’s visible region; it is not automatically a capture of all content beyond the current viewport. Refer to the binding’s API and verify the scope you need. Selenium’s screenshot operations are documented in the Python WebDriver API.

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

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. Its one-request API is a practical alternative when you do not need Selenium to exercise a particular login flow. The request below captures a public page; it does not log in to a protected account or bypass authentication.

Best Value
HP 14'' Laptop, Intel N150 CPU, 4GB RAM, 128GB SSD, Long Battery Life, 1TB Cloud Storage, Win 11 with Microsoft 365
  • 【Expansive Display】The 14 Non-touch display offers clear, and anti-glare coating, perfect for both work and entertainment.
  • Designed for mobility with a slim 0.71-inch profile and lightweight, making it easy to carry between home, office
  • 【Versatile Connectivity】 connected with multiple ports including USB 3.0 Type-C, and a headphone/mic combo jack, with Wi-Fi and Bluetooth for seamless wireless networking.
  • One Year Microsoft 365

See the ScreenshotNeo API documentation for authentication and request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
  • Cookie banners are accepted and removed, and known newsletter popups and chat widgets are removed before capture; each of these cleanup steps can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. Response headers identify the page verdict and billing status.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
  • The Free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Troubleshoot common failures

  • Cookie addition fails: WebDriver may not be on a page within the cookie’s valid domain. Visit the relevant site first, then add the correctly scoped cookie.
  • The screenshot shows a login page: Authentication may not have succeeded, the session may be invalid or expired, or the target may require additional state. Confirm the authorized login result before navigating to the capture page.
  • The screenshot is blank or missing content: Navigation readiness may have occurred before client-side rendering finished. Wait for a meaningful page element or other application-specific condition, then capture.
  • An explicit wait times out: Check that the locator matches the real authenticated page, that the page did not redirect, and that the condition is actually expected to become visible. Adjust the timeout based on the application rather than assuming one value fits all.
  • The image omits below-the-fold content: A standard current-window screenshot is not necessarily a full-page capture. Verify full-page support for your binding, browser, and driver, or capture the required region in a suitable way.
  • Wait durations behave unpredictably: Avoid combining implicit and explicit waits; use a consistent waiting strategy.

Protect credentials and screenshots

Login credentials, session cookies, and screenshots of account pages can expose private information. Keep them out of public logs and repositories, restrict access to saved images, and close the WebDriver session when the capture is complete. In the sample, the finally block calls driver.quit() even if a wait or screenshot operation fails.

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. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
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.