Use Playwright for Python to open the login page, fill in the site’s form, verify that authentication succeeded, and save the resulting page with page.screenshot(path="screenshot.png"). The example below is a template: you must adapt its URL, labels, button name, and success check to the website, and the site must permit browser automation.
Install Playwright before running the script
Follow the official Playwright for Python installation instructions to install the Python package and browser binaries. The required installation command can depend on your environment, so use the current instructions there rather than assuming the Python package alone includes a browser.
As an Amazon Associate I earn from qualifying purchases.
Set credentials in environment variables instead of embedding them in source code. For example, in a Unix-like shell, run export SITE_USERNAME='[email protected]' and export SITE_PASSWORD='your-password' before starting Python. Use your operating system’s equivalent environment-variable setup where needed, and avoid printing or logging credentials.
Log in and save the authenticated page as PNG
This synchronous example assembles documented Playwright interactions; it is not a tested script for any particular site. Replace the sample URL and accessible names with the labels and button text shown by your target website.
#1 Best Overall
- 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
import os
from playwright.sync_api import sync_playwright, expect
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.goto("https://example.com/login")
page.get_by_label("Email").fill(os.environ["SITE_USERNAME"])
page.get_by_label("Password").fill(os.environ["SITE_PASSWORD"])
page.get_by_role("button", name="Sign in").click()
# Replace with an element that only appears after successful login.
expect(page.get_by_role("button", name="Account")).to_be_visible()
page.screenshot(path="screenshot.png")
browser.close()
get_by_label() and get_by_role() use the page’s accessible names. If the site does not expose those names, choose a locator that matches its actual markup; selectors are not universal. A visible account control is only an example of an authentication check. Prefer a site-specific element or URL that demonstrates the signed-in state, so an error message or return to the login screen is not mistaken for success.
The screenshot call writes a PNG to screenshot.png in the script’s current working directory. Keep it after the successful-login check; otherwise the saved image may show the login page or an intermediate redirect.
Rank #2
- 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.
Handle MFA, redirects, and site-specific login behavior
The example assumes a conventional form with email and password fields and a sign-in button. Actual flows may redirect, require additional steps, or use labels and controls that differ. Adjust the interaction and success assertion for the site’s documented or permitted test flow. If sign-in requires an authenticator, passkey, or another human-mediated action, the script may need to pause for that step rather than trying to bypass it.
Use browser automation only where the site permits it, and do not attempt to defeat CAPTCHA or other access controls. A login flow that cannot be completed through an approved automation path cannot be made reliable merely by changing a selector.
Rank #3
- 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.
Choose what to capture
- Current viewport:
page.screenshot(path="screenshot.png")captures the page as currently rendered in the viewport. - Full scrollable page: use
page.screenshot(path="screenshot.png", full_page=True)to capture the full page rather than only the visible viewport. - One element: save a specific component with
page.locator(".your-selector").screenshot(path="element.png"). Replace the selector with one that identifies the element on your page.
Playwright can also return screenshot bytes for post-processing instead of writing directly to a path. For a straightforward PNG file, the path option is the simplest choice.
Reuse a signed-in state without exposing it
If you need to take later screenshots without repeating login, save browser-context storage after a successful sign-in with context.storage_state(path="playwright/.auth/state.json"). For subsequent runs, create a context with browser.new_context(storage_state="playwright/.auth/state.json"), then navigate to the authenticated page and verify the signed-in state before capturing. See Playwright’s authentication documentation for the storage-state workflow.
Rank #4
- 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.
Authentication state can include cookies and headers that allow someone to impersonate the account. Store it as a secret, restrict access, delete it when it expires or is no longer needed, and exclude its directory from version control using .gitignore. Do not commit it, including to a private repository.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Storage-state files may include cookies, local storage, IndexedDB, or virtual WebAuthn credentials depending on the application and the configured state options. Session storage is different: it is domain-specific, is not persisted across page loads, and Playwright does not provide a direct API to persist it. Whether saved state remains usable and which storage the site needs depend on that site’s authentication model.
Best Value
- 【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
Troubleshoot common failures
- Missing environment variable: Python raises a
KeyErrorwhen a named credential variable is unset. Set the variable in the environment that launches Python; do not put the password into the script as a shortcut. - Playwright cannot launch Chromium: install the browser binaries as directed in the official Playwright Python installation instructions. Installing the Python package by itself may not install the browser needed for the script.
- Locator does not find the field or button: the accessible label or button name differs from the example, or the page has not reached the expected state. Inspect the site’s form and use its actual accessible names; do not assume every site uses “Email,” “Password,” and “Sign in.”
- The success check times out: the chosen account element may not exist, the login may have failed, or the flow may require another step or redirect. Replace the example assertion with a marker unique to the authenticated page and account for the site’s actual login flow.
- The PNG shows the login page: the script may be capturing before authentication completes, or the check may not establish that login succeeded. Make the assertion site-specific and capture only after it passes.
- Saved state no longer signs in: site sessions can expire or require additional authentication data. Repeat the permitted login flow to create fresh state; do not assume a storage file works indefinitely.
Or skip the browser setup
If you need a screenshot of a publicly accessible page rather than a page behind your login, ScreenshotNeo offers a one-request screenshot API. It does not log in to websites or replace the authenticated Playwright workflow above.
With an API key, request a PNG by setting the output format:
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://stripe.com
-d format=png
-o shot.png
See the ScreenshotNeo API documentation for request options and response details. Its clean-shot flow accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses indicate the page verdict and billing status in headers. ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents and other MCP clients. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsSign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.
Frequently Asked Questions
Does Playwright save a screenshot as PNG by default?
Yes. The documented page.screenshot(path="screenshot.png") pattern writes the screenshot to the named PNG path.
Can I screenshot a page that requires login with ScreenshotNeo?
ScreenshotNeo’s described one-request screenshot API is for publicly accessible pages; it does not perform the website login shown in this Python workflow.
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.
Recommended Free Tools




