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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use Playwright to sign in with an account you are authorized to use, verify that the expected signed-in page has loaded, and then call page.screenshot(). DigiLocker’s current public sign-in flow starts with a registered mobile number and may require OTP verification; it is not a password-only flow. Because the authenticated page and its contents are private and account-specific, the example below shows where to complete the official verification without automating or logging sensitive credentials.

Capture a DigiLocker page after signing in

The safest general pattern is to let an authorized user complete DigiLocker’s current verification in a Playwright browser, check a reliable post-login marker, and capture only after that check succeeds. The code below is a template: it has not been tested against an authenticated DigiLocker account, and you must identify a stable selector that actually appears on the page you are permitted to access.

Prerequisites

  • Node.js and Playwright installed in a private project.
  • A DigiLocker account you are authorized to use, and permission to capture the target page.
  • A screenshot destination that is private and access-controlled if the page contains personal information.

Install Playwright if needed with npm install playwright. Save the following as capture-digilocker.mjs:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { chromium } from 'playwright';

const browser = await chromium.launch({ headless: false });
const context = await browser.newContext();
const page = await context.newPage();

try {
  await page.goto('https://digilocker.gov.in/', { waitUntil: 'domcontentloaded' });
  console.log('Complete DigiLocker sign-in and any verification in the browser.');
  await page.pause();

  // Replace this with a selector for a stable element on the authorized
  // signed-in page you intend to capture. Do not assume a public-page selector.
  await page.locator('REPLACE_WITH_SIGNED_IN_PAGE_SELECTOR').waitFor({
    state: 'visible',
    timeout: 30000
  });

  await page.screenshot({ path: 'digilocker-signed-in.png', fullPage: true });
} finally {
  await context.close();
  await browser.close();
}

page.pause() opens Playwright Inspector and pauses the script so you can finish the interactive sign-in yourself; resume the script after verification. The placeholder selector deliberately fails until you replace it with a visible, stable marker from the page you are authorized to capture. Prefer a semantic locator such as a role and accessible name, or a selector tied to a stable page element, rather than a brittle generated class.

#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

Confirm the right page before capture

Do not treat a successful navigation as proof of sign-in. Check an expected URL or a page element that only exists in the intended authenticated view. If the expected marker is absent, stop and inspect the browser rather than saving a sign-in, OTP, error, or account-selection screen as though it were the target.

For a fixed screenshot boundary, omit fullPage: true or set it to false. For a specific region, use a locator’s screenshot method after checking that the target element is visible. Screenshots can expose document details or identifiers; avoid capturing more than the task requires.

Sign-in and OTP considerations

DigiLocker’s current public sign-in page asks for a registered mobile number and offers a Next button. Its public OTP page asks for a six-digit OTP and presents resend and Aadhaar OTP alternatives. The route and verification steps can vary by account, so complete the verification currently presented by the official site; do not assume every user sees the same screens or that selectors stay fixed. See DigiLocker for the current public entry point.

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.

Do not put mobile numbers, OTPs, passwords, cookies, private documents, or other account data in source code, screenshots intended for public sharing, logs, or repositories. If you need to test the sign-in flow itself, use a legitimate test account and complete the live verification interactively. This workflow is implementation guidance, not a guarantee that DigiLocker permits unattended automation.

Reuse Playwright login state for later captures

Playwright can save browser storage state after sign-in and load it into a later context. This can avoid repeating the UI sign-in for tests that only need an already authenticated browser. A saved state is a credential: Playwright warns that it may contain sensitive cookies and headers capable of impersonating the account. Keep it private, exclude it from source control, and refresh it when the session expires.

Save state after authorized sign-in

After completing the manual sign-in in the preceding example, save the context state before closing it:

Rank #3
Sale
AKCHART 15.6'' AI Laptop with Office 365 12GB RAM 256GB SSD Win 11 Laptops
  • 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.
await context.storageState({ path: 'playwright/.auth/digilocker.json' });

Add the containing directory to .gitignore, for example:

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

Never commit or share the state JSON. Treat it as an active secret and restrict access to the machine and account that need it.

Load state in a later run

Create a new context with the saved file, then verify that the session is still valid before taking the screenshot:

Rank #4
HP Essential Laptop 2026, Intel CPU, 128GB Storage, Office 365, Windows 11
  • 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.
import { chromium } from 'playwright';

const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({
  storageState: 'playwright/.auth/digilocker.json'
});
const page = await context.newPage();

try {
  await page.goto('https://digilocker.gov.in/', { waitUntil: 'domcontentloaded' });
  await page.locator('REPLACE_WITH_SIGNED_IN_PAGE_SELECTOR').waitFor({
    state: 'visible',
    timeout: 30000
  });
  await page.screenshot({ path: 'digilocker-signed-in.png', fullPage: true });
} finally {
  await context.close();
  await browser.close();
}

Storage-state persistence covers cookies, local storage, IndexedDB, and passkey-based authentication in supported cases; standard storage state does not persist session storage. If the login depends on session storage, this reuse pattern may not preserve it. Playwright’s official guidance explains the supported authentication-state workflow and security warning: Playwright authentication.

Choose UI sign-in or saved state

Approach Use it when Trade-off
Complete UI sign-in for each run You need to validate the sign-in path or want a fresh authorized session. Interactive verification may be required on each run; do not script around account security checks.
Load saved storage state The test needs an already authenticated browser and the existing session remains valid. State is sensitive, can expire, and does not preserve session storage through the standard mechanism.
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 offers a one-request screenshot API; it is not a way to authenticate to a private DigiLocker account or capture a page that requires your signed-in browser session. Use it only for a URL that is accessible to the service without that private session. One example request is:

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

See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed. It also provides an MCP server so AI agents can take screenshots. The Free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000 screenshots. For a private DigiLocker page, use the authorized Playwright session instead.

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

Best Value
HP 14 inch Laptop, 2027 Edition, Intel N150 CPU, 4GB RAM, 128GB SSD, 1TB Cloud Storage, Long Battery Life, Win 11 with Microsoft 365
  • 【Powerful Performance】Equipped with an Intel N150 CPU, featuring up to 4.4 GHz, ensuring efficient and powerful multitasking capabilities.
  • 【Versatile Connectivity】Stay connected with multiple ports including USB 3.0 Type-C, USB 3.0 Type-A, and a headphone/mic combo jack, with Wi-Fi and Bluetooth for seamless wireless networking.

Troubleshooting

  • The script times out waiting for the marker: The selector may not match the authenticated page, sign-in may not have completed, or the session may have expired. Inspect the browser and replace the placeholder with a stable marker from the permitted target page.
  • The screenshot shows the sign-in or OTP screen: Do not proceed as if authenticated. Complete the current verification in the official UI and confirm the intended page marker before capturing.
  • A saved state opens a signed-out page: The session may have expired or the application may depend on session storage, which standard Playwright storage-state files do not persist. Complete a fresh authorized sign-in and save a new state if appropriate.
  • The screenshot contains private data: Restrict access to the output, remove unnecessary content from the capture, and do not publish or log account or document details.
  • The page looks different than expected: DigiLocker’s flow and authenticated content can vary by account and may change. Base assertions on the target account’s current page, not assumptions about a universal dashboard.

What DigiLocker is

DigiLocker describes itself as a secure cloud-based platform for storing, sharing, and verifying documents and certificates. Its official site lists 70+ crore registered users and 900+ crore issued documents, figures published by DigiLocker and last updated September 28, 2026; they are not independently audited counts. The signed-in page and its document contents remain account-specific and cannot be verified from the public sign-in page. See DigiLocker’s about page.

Frequently Asked Questions

Can Playwright take a screenshot without signing in?

Only of pages that are publicly accessible. A private account page requires an authorized signed-in session.

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

Does Playwright save DigiLocker session storage in its standard state file?

No. Standard Playwright storage state does not persist session storage.

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.