Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › browser automation

How to Take a Playwright Screenshot of a DigiLocker Page After Signing In

By Freedom251 Team · · 7 min read

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.

To capture a DigiLocker page after signing in, run Playwright in a browser context that has completed the account’s current verification, confirm that the expected signed-in page has loaded, and then call page.screenshot(). DigiLocker’s public sign-in flow currently starts with a registered mobile number and may require a six-digit OTP; do not assume a password-only or unattended login will work. The example below deliberately pauses for you to complete the authorized sign-in yourself, rather than handling credentials or OTPs in code.

What you need before capturing a signed-in page

  • A DigiLocker account you are authorized to use, and permission to access any documents shown in the capture.
  • Node.js and Playwright installed in a project. The example uses Playwright’s JavaScript library with Chromium.
  • A private place to save the screenshot. Treat it as sensitive if it shows personal details, document names, or other account information.

DigiLocker describes itself as a cloud platform for storing, sharing, and verifying documents and certificates. Its public page reports 70+ crore registered users and 900+ crore issued documents, figures published by DigiLocker and marked updated September 28, 2026; they are not independently audited counts. A signed-in page and its contents are account-specific, so those public figures do not establish what any particular account will show.

As an Amazon Associate I earn from qualifying purchases.

Take the screenshot with Playwright

This script opens the official DigiLocker site, gives you control of the browser to complete the current sign-in and verification flow, waits for you to confirm that you are on the intended page, and saves a full-page PNG. It avoids automating OTP entry or embedding account secrets. Because the authenticated interface is private and can change, the script uses a human confirmation rather than guessing a dashboard selector.

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.
  1. Install Playwright and Chromium: run npm init -y, then npm install playwright, then npx playwright install chromium.
  2. Save this as capture-digilocker.mjs:
    import { chromium } from 'playwright';
    import { createInterface } from 'node:readline/promises';
    import { stdin as input, stdout as output } from 'node:process';
    
    const startUrl = 'https://www.digilocker.gov.in/';
    const browser = await chromium.launch({ headless: false });
    const context = await browser.newContext({
      viewport: { width: 1440, height: 1000 },
    });
    const page = await context.newPage();
    const rl = createInterface({ input, output });
    
    try {
      await page.goto(startUrl, { waitUntil: 'domcontentloaded', timeout: 60000 });
      console.log('In the browser, open Sign In and complete the verification for your authorized account.');
      await rl.question('When the intended signed-in page is visible, press Enter here to capture it. ');
    
      // Check the URL and visible page yourself before capturing account data.
      console.log(`Current page: ${page.url()}`);
      await page.screenshot({ path: 'digilocker-signed-in.png', fullPage: true });
      console.log('Saved digilocker-signed-in.png');
    } finally {
      rl.close();
      await context.close();
      await browser.close();
    }
  3. Run it: node capture-digilocker.mjs. Complete the sign-in flow in the opened browser. DigiLocker’s public page currently asks for a registered mobile number; its OTP page asks for a six-digit code and offers resend and Aadhaar OTP alternatives. The options presented can vary by account and may change.
  4. Verify before pressing Enter: ensure the browser is showing the intended post-login page, not the sign-in or OTP screen. The script prints the current URL as a basic check; for a robust automated test, replace the manual pause with an assertion for a stable page element you have verified in your authorized account.

The example is an implementation pattern, not a tested DigiLocker automation recipe. The public documentation and pages do not establish that unattended sign-in is supported or guarantee any particular dashboard selector. If you add a locator assertion, inspect the page in your own authorized session and choose an element whose wording or role is stable enough for your test.

#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

Make the capture more targeted

  • Capture only the current viewport by changing fullPage: true to fullPage: false, or omit the option. This avoids a tall image if only the visible region matters.
  • Use a specific output path such as screenshots/digilocker.png; create that directory first.
  • For a test-runner assertion, Playwright supports screenshot assertions, but compare only a stable, non-sensitive page or a deliberately redacted fixture. A real account’s document data can vary and should not be committed as a golden image.
  • Keep the browser visible while completing verification. Do not attempt to bypass account checks or automate access beyond what the account and service permit.

Reuse a signed-in Playwright state carefully

For repeated tests, Playwright can save authenticated browser storage state and load it into a later context. This can skip repeated interactive sign-in while the session remains valid, but it also creates a sensitive file: cookies and headers in it may allow someone to impersonate the account. The standard storage-state mechanism can include cookies, local storage, IndexedDB, and passkey-based authentication; session storage is not persisted by that mechanism.

Save state after an authorized interactive sign-in

After completing a successful sign-in in a script, save the state before closing the context:

await context.storageState({ path: 'playwright/.auth/digilocker.json' });

Create playwright/.auth before running this code. Add the directory to .gitignore so the account state is not checked into source control:

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

Load it in a later run

Create a fresh context using the saved state, then navigate to the intended page and verify that the session is still authenticated:

const context = await browser.newContext({
  storageState: 'playwright/.auth/digilocker.json',
});
const page = await context.newPage();
await page.goto('https://www.digilocker.gov.in/', { waitUntil: 'domcontentloaded' });

Saving state does not guarantee that a future visit remains signed in. If the service expires the session or requires verification again, use the authorized interactive flow to refresh it. Protect the state file with the same care as credentials; do not paste it into tickets, logs, chat, or a public repository.

Choose UI login or saved state by test purpose

Approach Best for Trade-off
Complete the sign-in UI each run Testing the sign-in and verification path itself Requires interactive/account-dependent verification and may not be suitable for unattended runs.
Load saved storage state Tests that need an already authenticated browser State is a sensitive secret and can expire; standard storage state does not persist session storage.

Keep account data and authentication secrets private

  • Never put passwords, OTPs, mobile or Aadhaar identifiers, cookies, or storage-state JSON in source code or a repository.
  • Do not print authentication state or private page contents to logs.
  • Store screenshots outside public folders and review the image before sharing it. A screenshot may reveal personal information even if the script contains no credentials.
  • Use a legitimate test account and only capture pages you are allowed to access. Avoid bypassing CAPTCHA, OTP, or other account protections.

Troubleshooting

The capture shows the sign-in screen

The browser may not have completed verification, the session may have expired, or the intended page may require another navigation after login. Inspect the visible page and current URL before capture. If loading saved state, refresh it through the authorized interactive flow when needed.

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.

The OTP step does not match the script

The example intentionally does not automate OTP entry. Follow the verification method currently offered to your account in the browser, which may include a six-digit OTP, resend, or Aadhaar OTP. Do not hard-code a one-time code.

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

A locator assertion fails

A selector copied from another account or an earlier interface may no longer identify the same element. Inspect the page in the authorized session, use a role or label when practical, and assert a marker that actually distinguishes the intended signed-in state. Do not treat a successful navigation alone as proof of authentication.

The state file loads but the account is signed out

The session may have expired, or the required authentication data may not be persisted by the storage-state mechanism—for example, session storage is not included by default. Reauthenticate through the normal flow and save fresh state; do not try to reconstruct or expose private cookies.

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.

The screenshot is blank, clipped, or unexpectedly long

Confirm that the page finished rendering and that the browser is on the intended view. Use viewport capture instead of full-page capture if only the visible screen is needed. For pages whose content loads as you scroll, a full-page capture can differ from what was initially visible; validate the result rather than assuming every region has loaded.

Playwright cannot launch Chromium or times out

Install the browser binaries with npx playwright install chromium. If navigation times out, check network access and whether the site is responding, then increase the navigation timeout only when there is a concrete reason; a longer timeout does not resolve a blocked or failed sign-in.

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

For a public page, ScreenshotNeo can return a screenshot with one GET request. This does not replace the authenticated Playwright workflow above: a public URL capture cannot verify or reveal a private DigiLocker dashboard. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status. It also provides an MCP server with screenshot, page-info, and PDF tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

Example for a public page only; see the ScreenshotNeo API documentation for request options:

Best Value
HP Essential Laptop, Intel N150 CPU, 4GB DDR5 RAM, 128GB SSD, Long Battery Life, 1TB Cloud Storage, Win 11 with Microsoft 365
  • 【Powerful Performance】Equipped with Intel N150 CPU, featuring up to 4.4 GHz, ensuring efficient and powerful multitasking capabilities.
  • 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
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://www.digilocker.gov.in/ -o shot.webp

ScreenshotNeo is a website screenshot API and MCP server made by Yorker Media. Learn more at ScreenshotNeo, or sign up for 1,000 free screenshots per month with no card.

Frequently Asked Questions

Can Playwright take a screenshot of my DigiLocker dashboard without signing in?

No. A private, account-specific page requires an authorized signed-in browser session; a screenshot of a public URL cannot show that account’s dashboard.

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

Does saving Playwright storage state preserve session storage?

No. Playwright’s standard storage-state mechanism does not persist session storage.

Can I automate DigiLocker OTP entry?

The example leaves verification to you in the browser. The public sign-in pages establish that verification can involve OTP, but they do not establish that unattended automation is supported.

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.

browser automationDigiLockerJavaScriptPlaywrightscreenshots

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.

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.