October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Chrome

How to Take High-Resolution Screenshots with cy.screenshot() in Cypress

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.

To produce a higher-resolution Cypress screenshot, change two different layers: set the application layout with cy.viewport(), then set the headless Chrome window and device scale factor in the before:browser:launch hook. Cypress explicitly notes that cy.viewport() does not simulate devicePixelRatio. Verify the resulting file or screenshot metadata instead of assuming that a larger CSS viewport created a denser image.

The working configuration

In a Cypress project using JavaScript, add a browser-launch hook to cypress.config.js (or the equivalent TypeScript configuration). The following follows Cypress’s documented launch pattern for headless Chrome, using a 1,400 × 1,200 browser window and a device scale factor of 2. The dimensions are configuration values, not guaranteed output dimensions on every Cypress, Chrome, or operating-system combination.

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      on('before:browser:launch', (browser, launchOptions) => {
        if (browser.name === 'chrome' && browser.isHeadless) {
          launchOptions.args.push('--window-size=1400,1200')
          launchOptions.args.push('--force-device-scale-factor=2')
        }
        return launchOptions
      })
    },
  },
})

Then set the CSS viewport and capture the desired area in a spec:

describe('high-resolution capture', () => {
  it('captures the page at a controlled viewport', () => {
    cy.viewport(1280, 800)
    cy.visit('https://example.com')
    cy.screenshot('high-resolution-page', {
      capture: 'viewport',
      overwrite: true,
    })
  })
})

The launch arguments affect the browser’s screen and pixel density; cy.viewport(1280, 800) controls the application’s layout viewport in CSS pixels. Keep those responsibilities separate when you tune a baseline.

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.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • 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

Viewport, screen size, scale factor and output pixels

cy.viewport() is a CSS-layout control

Cypress documents a default viewport of 1000 × 660 until a viewport command or configuration changes it. The command changes the dimensions that responsive CSS and JavaScript observe. It does not emulate a Retina display and does not change devicePixelRatio; see the cy.viewport() API.

Browser launch arguments provide density

For headless Chrome, --window-size=width,height sets the browser screen dimensions and --force-device-scale-factor=2 requests a two-times device scale factor. Cypress shows this approach in its before:browser:launch documentation. The final bitmap can still vary with browser mode, operating system, Chrome version, and Cypress version.

The screenshot scale option is not a Retina switch

The scale option scales the application to fit the browser viewport. Cypress defaults it to false for viewport captures and coerces it to true for runner captures. It is a fit-to-window behavior, not a documented resolution multiplier; do not substitute it for a device scale factor.

Choose exactly what to capture

cy.screenshot() captures the application under test by default. Select the scope deliberately:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • 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
Scope Example What it contains
Viewport { capture: 'viewport' } The currently visible application area.
Full page { capture: 'fullPage' } The page from top to bottom, assembled from successive scroll captures.
Runner { capture: 'runner' } The browser viewport together with the Cypress Command Log.
Element cy.get('.report-card').screenshot(...) One DOM element, optionally with padding.

For a full-page image, Cypress scrolls and stitches multiple captures. Fixed or sticky headers can therefore appear repeatedly or in unexpected positions; inspect the result before using it as a visual baseline.

// Full page
cy.screenshot('long-page', { capture: 'fullPage' })

// One element, with 12 CSS pixels of padding
cy.get('.report-card').screenshot('report-card', { padding: 12 })

// A clipped rectangle in pixel coordinates
cy.screenshot('cropped', {
  capture: 'viewport',
  clip: { x: 20, y: 20, width: 400, height: 300 },
})

Element padding and clip coordinates change the capture area, not the device density.

Make the page deterministic before capture

  1. Set one viewport. Use cy.viewport() in the test or configure a project-wide value so every baseline has the same CSS dimensions.
  2. Wait for meaningful application state. Visit the page, wait for the API-backed content or a specific selector, and assert that loading indicators are gone. A screenshot can be pixel-perfect yet still capture the wrong state if the app is mid-render.
  3. Control animations. Cypress disables timers and CSS animations during screenshot capture by default, but asynchronous application updates can still race the command. Use an assertion such as cy.get('[data-cy=dashboard]').should('be.visible') before capturing.
  4. Use stable data. Freeze dates, randomized IDs, network responses, feature flags, and user-specific content when the image is a visual-regression baseline.
  5. Keep the environment fixed. Cypress recommends generating and comparing screenshots in the same environment with a fixed viewport. Operating systems, browser versions, display scaling, and installed fonts can all alter rendering; the guidance is in Visual testing in Cypress.

Verify the actual resolution

Do not infer output dimensions from the requested window or scale factor. Use Cypress’s screenshot callback or the Node after:screenshot event. Cypress exposes details including dimensions, scaled, and pixelRatio; see the after:screenshot API.

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      on('after:screenshot', (details) => {
        console.log(JSON.stringify({
          path: details.path,
          dimensions: details.dimensions,
          scaled: details.scaled,
          pixelRatio: details.pixelRatio,
        }))
      })
    },
  },
})

You can also inspect the saved PNG or JPEG with an image-information utility in your build pipeline. Record the measured width, height, and (when supplied) pixel ratio as build artifacts. A requested factor of 2 is not proof that every output pixel doubled.

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

Common problems and fixes

The image is the same size after changing cy.viewport()

Cause: the command changed CSS layout but not device density. Fix: add the Chrome launch arguments in before:browser:launch, run a headless Chrome browser, and verify the resulting dimensions.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • 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.

The launch arguments have no effect

Cause: the hook only applies the arguments for headless Chrome in the example, or the selected browser is not Chrome. Fix: confirm the browser object in the hook, place the code under the active e2e.setupNodeEvents (or component-testing equivalent), and return launchOptions.

A full-page capture repeats a header

Cause: Cypress stitches screenshots while scrolling, so fixed and sticky elements can be present in more than one segment. Fix: review the stitched artifact, temporarily disable the sticky behavior for the test, or capture a viewport or specific element when a stitched page is not appropriate.

Text or spacing differs between machines

Cause: fonts, operating-system rasterization, browser versions, or display scaling differ. Fix: run visual tests in the same container or CI image, install identical fonts, pin the browser and Cypress versions, and use one fixed viewport.

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

The screenshot catches a loading state

Cause: the screenshot command ran before the application finished its asynchronous work. Fix: wait on a stable selector or network-driven assertion, then capture; avoid arbitrary delays unless no observable readiness signal exists.

Output files are unexpectedly large or slow

Cause: a large full-page bitmap at a high device scale factor contains many more pixels. Fix: capture only the required scope, use viewport or element mode for regression tests, and reserve a higher scale factor for deliverables that need it. Keep the same settings for every baseline so file-size changes are meaningful.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • 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

Performance and reliability choices

  • Use viewport captures for fast checks. They avoid full-page scrolling and stitching.
  • Use full-page only when the document length matters. Long pages require multiple scrolls and can expose sticky-element artifacts.
  • Capture elements for focused assertions. This reduces noise from unrelated page changes.
  • Separate diagnostic images from baselines. Runner captures include Cypress’s UI and are useful for debugging, but they are not the application-only artifact used for most visual comparisons.
  • Pin the execution environment. A consistent browser, operating system, fonts, viewport, and scale factor improves repeatability more than simply requesting a larger image.
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 provides a GET-based screenshot API and an MCP server for developers and AI agents. One request returns PNG, JPEG, WebP, or PDF. Its cleaning step accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report X-Page-Verdict and X-Billed.

For a one-off capture:

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 complete option list and parameter names in the ScreenshotNeo documentation. It supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets or any viewport, Retina scale, PDF paper and margin controls, custom CSS and JavaScript, clicks before capture, hidden selectors, waits for selectors, delays or network idle, request and resource blocking, custom headers, cookies, user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed image links, asynchronous jobs with signed webhooks, 100-URL bulk calls, a usage API, and an OpenAPI specification.

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

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' }); const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also exposes take_screenshot, get_page_info, and capture_pdf through MCP clients such as Claude or Cursor. Every feature is included on every plan: 1,000 shots per month free with no card; Starter is $5 for 3,000, Growth $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000, and Business $249 for 1,000,000. Yearly billing gives two months free. Create a free ScreenshotNeo account to start with the 1,000 monthly shots.

Frequently asked questions

Can I use a device preset instead of Chrome flags?

Cypress can emulate named viewport dimensions, but the documented high-density approach for headless Chrome is still the browser launch argument plus verification of the produced artifact. Do not assume a preset changes the physical pixel ratio.

Which image format should a Cypress screenshot use?

Choose the format supported by your Cypress configuration and downstream comparison tools. The resolution method is independent of whether the artifact is PNG or JPEG; verify dimensions after capture.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【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.

Does a two-times scale factor always mean twice the width and height?

No. The factor is a browser request. Window size, viewport behavior, browser mode, and stitching can affect the final dimensions, so inspect metadata or the file itself.

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

Should visual tests compare screenshots from different operating systems?

For reliable pixel comparisons, avoid mixing environments. Use the same operating system, browser version, fonts, viewport, and display-scaling assumptions for both the baseline and the candidate image.

Frequently Asked Questions

Can I use a device preset instead of Chrome flags?

Cypress viewport presets control layout dimensions; the documented high-density method for headless Chrome remains the browser launch arguments, followed by checking the generated artifact.

Which image format should a Cypress screenshot use?

Use the format accepted by your Cypress setup and comparison tooling. PNG or JPEG does not change how device scale factor is configured; verify the resulting dimensions.

Does a two-times scale factor always double image width and height?

No. It is a browser request, while viewport, browser mode, and full-page stitching affect the final bitmap. Measure the file or inspect screenshot metadata.

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

Can visual tests compare screenshots made on different operating systems?

They can, but pixel differences from fonts, browser versions, rasterization, and display scaling make results less reliable. Keep baseline and candidate environments identical when possible.

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.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.