What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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
To screenshot a page behind login with Cypress, establish an authenticated session, visit the protected route, verify that the expected page is visible, and then call cy.screenshot(). For reusable login state, wrap the login flow in cy.session(); it restores cookies and browser storage, but you still need to navigate to the page you want to capture.
Set up authentication before visiting the page
The right login setup depends on your application. If it provides a suitable test login endpoint, an API request can establish a cookie-based session without replaying the UI login flow. A UI login is useful when the test also needs to exercise the user-facing authentication journey. Cypress documents both approaches in its API testing guide and session command reference.
Reusable API login example
This example assumes the application accepts a POST /api/login request and exposes /api/me for checking the logged-in user. Replace those endpoints and assertions with the ones your app supports.
const loginAs = (username) => {
cy.session(username, () => {
cy.request('POST', '/api/login', {
username,
password: Cypress.env('TEST_PASSWORD'),
})
}, {
validate() {
cy.request('/api/me').its('status').should('eq', 200)
},
})
}
describe('authenticated page screenshots', () => {
it('captures the account page', () => {
loginAs(Cypress.env('TEST_USERNAME'))
cy.visit('/account')
cy.contains('Account').should('be.visible')
cy.screenshot('account-page', { capture: 'viewport' })
})
})
For cookie-based authentication, cy.request() uses Cypress’s browser cookie jar. The test still visits /account after session setup, because a restored session does not select or load the page to capture.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
Using a UI login flow
If your test must authenticate through the interface, put the UI steps inside the cy.session() setup callback instead of the API request. Keep the same validation and protected-page assertions: a successful login form interaction alone does not prove the session is valid or that the requested route loaded.
Reuse and validate the session safely
cy.session() caches and restores cookies, localStorage, and sessionStorage. Cypress clears cookies and web storage before running session setup. With test isolation enabled, it also clears the page; after setup or restore, visit the target route explicitly.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- Validate restored state: provide a
validate()callback, such as a request to an authenticated endpoint. If validation fails after restoration, Cypress reruns the setup; if it fails immediately after setup, the test fails. - Keep session IDs non-sensitive: Cypress displays session IDs in the reporter. Use a stable identifier such as a role or username, not a password or token.
- Know the reuse boundary:
cacheAcrossSpecs: truecan reuse a session across specs only within the same Cypress run on the same machine. A new run starts without that cache, and each parallel CI machine establishes its own session. - Assert the destination: after
cy.visit(), assert a recognizable authenticated-page element. This catches expired sessions, failed logins, and redirects before they produce misleading screenshots.
Choose what the screenshot should include
The cy.screenshot() command captures the page currently loaded in the test. Choose the capture scope that matches the artifact you need.
Free tools Windows power users keep installed
One-click scans. No signup required.
| Capture | Example | Use it for |
|---|---|---|
| Viewport | cy.screenshot('account', { capture: 'viewport' }) |
The visible browser viewport. |
| Full page | cy.screenshot('account', { capture: 'fullPage' }) |
The application from top to bottom. |
| Runner | cy.screenshot('account', { capture: 'runner' }) |
Debug context that includes the Cypress runner. |
| Element | cy.get('[data-cy="account-summary"]').screenshot() |
A selected element rather than the whole page. |
For app captures, the blackout option can hide selected elements. It does not apply to runner captures, and Cypress forces automatic failure screenshots into runner mode. Review any artifact before sharing or uploading it, especially if the page can show account details, personal information, or tokens.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Make capture timing and output predictable
Wait for the intended page state
Screenshot capture is asynchronous; Cypress’s command reference says it takes around 100 ms, during which the page may change. Wait for the content you need and assert it before capture. Cypress disables timers and animations by default during capture to reduce movement, but that does not replace a readiness check for data loaded by your app.
Use stable filenames and know where files go
Screenshots default to cypress/screenshots. A named screenshot is saved under the adjusted spec path; duplicate names are incremented unless overwrite: true is set. Before cypress run, Cypress clears the screenshots folder by default. If preserving it across runs is intentional, set trashAssetsBeforeRuns: false in configuration. See the screenshots and videos guide and configuration reference.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Use screenshots in interactive runs and CI
You can call cy.screenshot() in both cypress open and cypress run. Cypress automatically captures a screenshot when a test fails in cypress run, including CI; it does not automatically capture failure screenshots in cypress open. Set screenshotOnRunFailure: false to disable automatic failure captures. Cypress Cloud can display screenshots from a CI run, or you can export them through your CI provider’s artifact mechanism.
Troubleshoot login-page screenshots
- The screenshot shows the login page: the session may not have been established, may have expired, or may not apply to the target route. Add a session validation request and assert an authenticated page element after visiting the route.
- The session works once but fails on restore: check that the session setup recreates all required authentication state and that
validate()checks a real authenticated endpoint. Cypress can rerun setup when validation fails after restoration. - A spec unexpectedly starts logged out: confirm the test visits the target after
cy.session(). Test isolation clears the page, while session setup clears cookies and web storage before establishing state. - Parallel CI jobs repeat login: this is expected when jobs run on separate machines. Cross-spec caching applies within one run on one machine, not across machines or new runs.
- Private data appears in an artifact: use
blackoutfor supported app captures, avoid runner capture for sensitive output, and review screenshots before sharing. Blackout selectors do not affect runner screenshots. - Old images disappear after a run: Cypress clears the screenshots folder before
cypress runby default. SettrashAssetsBeforeRuns: falseif that cleanup is not wanted.
Or skip the browser setup
If you need a screenshot through an API instead of a Cypress browser test, ScreenshotNeo accepts one GET request with a URL and returns an image or PDF. For an authenticated page, supply authentication using the supported request options documented for the API; an external screenshot request does not automatically inherit Cypress’s browser session.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Example request, using a public page URL as the target:
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 authentication and options. Cookie banners are accepted and removed along with known 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 response headers report the page verdict and billing status. Its MCP server provides screenshot tools for AI agents, and the free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month, with no card required.
Frequently Asked Questions
Does Cypress authenticate a page when I call cy.screenshot()?
No. Establish login state and visit the protected route before capturing.
Can I capture just one element on the logged-in page?
Yes. Call .screenshot() on the element selected with cy.get().
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.

