October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Why Does My Playwright Screenshot Show the Login Page Instead of the Dashboard?

A login-page screenshot usually means the browser context lacks valid auth state or capture happened before the dashboard was ready. Diagnose it with saved state, explicit assertions, and traces.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Because the screenshot captures the page state at that moment: Playwright may be using a fresh or expired browser context, the login flow may not have finished setting authenticated state, or the test may capture before the dashboard is ready. Reuse valid authentication state, wait for a dashboard-specific URL or UI condition, and assert it before taking the screenshot.

Check whether the page has authenticated state

Playwright tests run in isolated browser contexts. Signing in in one context does not automatically sign in a separately created context. If the screenshot test opens a new page or context without the right state, it will normally see the login page.

As an Amazon Associate I earn from qualifying purchases.

Use the intended saved state

Playwright’s authentication guide recommends signing in in a setup project, checking that sign-in succeeded, saving the browser state, and configuring dependent tests to use that state. Make sure the screenshot test actually uses the saved file through its project or test configuration.

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

Check whether the state is still valid

Saved cookies or other authentication data can expire. If the application has invalidated the session, recreate the state by signing in again and confirming the successful destination before saving it. The guide also notes that UI mode does not run the setup project by default, so a test that works in a normal run may lack fresh state when run from UI mode.

Account for sessionStorage

Playwright’s ordinary storageState does not persist sessionStorage. If your application keeps sign-in data there, use the save-and-restore approach described in the authentication guide, such as an initialization script that restores the needed values for the page. Do not assume that a storage-state file contains every kind of browser state your app uses.

Wait for the login flow and dashboard, not just the click

A completed click only means Playwright performed the click; it does not prove the application finished its redirects, set cookies, or rendered the authenticated view. After submitting credentials, wait for the final URL or a stable dashboard-specific element. Then take the screenshot.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

For example, adapt the URL and locator to your application:

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.
import { test, expect } from '@playwright/test';

test('captures the dashboard after login', async ({ page }) => {
  await page.goto('/login');
  // Perform the application's login steps here.
  await page.waitForURL('**/dashboard');
  await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
  await page.screenshot({ path: 'dashboard.png' });
});

The URL wait catches a redirect to the expected route; the visibility assertion checks that the dashboard itself has appeared. Use a locator that identifies a real, stable part of your authenticated interface. Playwright’s page assertions retry until their condition is met, and its locator guidance explains how to choose resilient locators.

Make authentication setup safe and repeatable

If several tests need a signed-in session, prepare it once in a setup project, verify sign-in, and save the state only after success. Configure the dependent project to use that state. Playwright describes both shared-account setup and per-worker authentication in its authentication guide.

  • A shared account can suit tests that do not modify shared server-side data in ways that interfere with one another.
  • Tests that change shared server-side state may need separate accounts or per-worker state to avoid collisions.
  • Never commit authentication-state files to source control. They can contain cookies and headers that could allow someone to impersonate the account.

Why load-state waits can give false confidence

A document reaching a load state is not the same as the app proving that the user is authenticated or that the dashboard has rendered. Waiting for the expected URL and asserting a dashboard element expresses the condition the screenshot actually needs.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Playwright’s Page API documents load-state waits; it discourages using networkidle as a test-readiness signal. Prefer a web assertion on the URL or application UI rather than waiting for all network activity to stop.

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.

Use a trace to find where the state changes

If the login page still appears, capture a Playwright trace and inspect it in Trace Viewer. It presents action timing, source locations, DOM snapshots, screenshots, and logs, which can help identify whether login failed, a redirect returned to sign-in, or the screenshot happened too early. See the Trace Viewer guide.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting by symptom

Symptom Likely cause What to check or change
Login succeeds in one test, but the screenshot test sees sign-in The tests use separate isolated contexts, and the screenshot test was not given the saved state. Configure the screenshot project or test to use the intended storageState file.
The screenshot test used to work, then started showing sign-in Saved authentication state may have expired or been invalidated. Run setup again, verify the authenticated destination, and replace the stale state file.
Works in a normal test run but fails in UI mode UI mode does not run the setup project by default. Run the setup project or otherwise ensure fresh authentication state is available before the dependent test.
The URL is correct but the screenshot is still incomplete The route changed before the dashboard UI finished rendering. Assert a dashboard-specific heading, landmark, or other stable element before capture.
Login appears despite a saved state file The app may rely on sessionStorage, which ordinary Playwright storage state does not persist, or the saved state may be stale. Check the app’s storage mechanism; restore session storage with the documented initialization-script approach if needed, or refresh the state.
Failure is hard to reproduce from logs alone The timing of the login, redirects, and screenshot is unclear. Inspect a trace for action timing, DOM snapshots, screenshots, and logs.

Or skip the browser setup

If you need a screenshot of a publicly accessible page rather than an authenticated application, ScreenshotNeo can return an image or PDF with one GET request. It is not a substitute for Playwright’s authenticated test flow: do not send private credentials or expect it to capture a dashboard that requires your test’s session.

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. It also offers an MCP server for AI agents, and includes 1,000 screenshots a month on its free plan with no card; paid plans start at $5 for 3,000 shots.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Sign up for 1,000 free screenshots a month, with no card required.

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

Frequently Asked Questions

Can I use the same Playwright storage-state file for every test?

It depends on whether tests interfere through shared server-side data. Tests that mutate shared state may need isolated accounts or per-worker authentication state.

Does a successful login click mean the dashboard is ready?

No. Wait for the final URL or assert a stable dashboard element before capturing.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver 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.