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

Choose the treatment that matches what your Cypress screenshot is meant to prove. To capture the page as a visitor who has already consented would see it, set the application’s real consent cookie before cy.visit(). To hide the banner only in the image, use cy.screenshot()’s selector-based blackout option, where the capture mode supports it. If a real network response controls consent state, intercept that request and supply a suitable test response. In every case, wait for a reliable application-ready signal before capturing.

These approaches are not interchangeable: a saved cookie represents application state, a stubbed response represents a state supplied by the test, and blackout changes the screenshot pixels without dismissing the live banner.

Choose the result your screenshot should represent

Before changing a test, decide whether the banner is part of what you are testing or merely an obstruction in a visual artifact. A screenshot taken after consent is recorded should be produced by setting the application’s actual consent state. A screenshot intended to show the rest of the page without evaluating consent can use blackout. A network stub makes sense only when the application gets its consent state from a request that your test can intercept.

What you need Approach What the screenshot represents Important limitation
Show the post-consent experience Set the application’s known consent cookie before visiting The application after its consent state has been recorded Cookie name, value, and behavior depend on the app. Cypress documents setting a known cookie value.
Make an image without the banner, without changing consent state Use the blackout selector option on cy.screenshot() The capture with selected pixels blacked out It does not dismiss the banner in the page and does not apply to runner captures. See the screenshot API.
Reproduce a server-defined consent state Intercept and stub the actual state-setting request The state implied by the response your test supplies The request and response must match the app; a cached response may bypass network interception. See the intercept API.

For functional consent coverage, do not black out the banner and treat the resulting image as evidence that consent works. Keep tests that exercise the banner and its choices separate from visual captures of the post-consent page.

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.

Set the real consent cookie before visiting

Use this option when the screenshot should show the same application state as a returning visitor who has already made a consent choice. Cypress’s FAQ demonstrates setting a known cookie in beforeEach. The example below uses illustrative values: replace both with the cookie name and accepted value your application actually recognizes.

beforeEach(() => {
  cy.setCookie('cookieConsent', 'accepted')
  cy.visit('/')
})

Setting the cookie before navigation matters: the browser sends the cookie as the page is requested, so server-side or client-side application logic can observe the intended state during startup. If you set it only after the page has loaded, the banner may already have rendered or the app may already have decided what to display.

  1. Find the consent cookie used by the application, including its exact name and accepted value. Do not assume that a cookie called cookieConsent or a value of accepted is universal.
  2. Place cy.setCookie() in the test setup that runs before the visit, such as the shown beforeEach.
  3. Visit the route to be captured only after the cookie is set.
  4. Wait for an application signal that the intended page state is ready, then capture or assert against the page.

A cookie can be present yet still fail to suppress the banner. The application may require a different value, another consent field, a particular domain or path, or a server-side state. Verify the app’s own consent behavior rather than continually changing screenshot timing to compensate for an incorrect cookie.

Black out the banner in the screenshot only

When the only requirement is a clean visual artifact and the test should not alter the application’s consent state, use the screenshot command’s blackout option. Cypress accepts an array of selectors. It blacks out matching regions in the image; it does not remove the banner from the live page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cy.visit('/')
cy.get('[data-testid="page-ready"]').should('be.visible')
cy.screenshot('page-without-consent-banner', {
  blackout: ['[data-testid="cookie-banner"],
})

In this example, [data-testid="page-ready"] and [data-testid="cookie-banner"] are illustrative selectors. Replace them with selectors that exist in your application. Check the Cypress screenshot API documentation for the supported options and capture-mode behavior.

Blackout is useful when changing cookies or mocking a response would make the test less representative, or when the banner is irrelevant to the particular image. It is not suitable when you need to inspect the banner’s appearance, prove that a consent choice closes it, or capture a runner screenshot: Cypress specifies that blackout does not apply to runner captures.

Stub a real consent request when the app uses one

Some applications obtain consent configuration or visitor state from a network request. If that request determines whether the banner appears, intercept it before navigation and return a fixture or handler response that matches the test state. Cypress supports spying on and stubbing requests with cy.intercept().

// Illustrative structure only: use the application's real route and response.
cy.intercept('GET', '/the-apps-real-consent-route', {
  fixture: 'consent-state.json',
})
cy.visit('/')
cy.get('[data-testid="page-ready"]').should('be.visible')
cy.screenshot('page-after-consent-state')

The route, fixture name, response body, and readiness selector above are examples, not a reusable consent contract. Determine the request and response from the application itself; inventing an endpoint or response shape can make a test that passes without representing the real app. Register the intercept before the visit so it is in place when the page makes the request.

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

There is an important cache edge case: a response served from the browser cache does not reach the network layer, so Cypress cannot intercept it there. If the expected interception does not occur, establish whether the request is actually sent rather than assuming the route matcher is wrong. See the Cypress intercept documentation for interception behavior.

Wait for a stable page state before capturing

A screenshot can be inconsistent even when the consent approach is correct if the page is captured while it is still rendering. Prefer a signal tied to the state you need: a completed request, a visible application-ready element, or an app-set class or attribute that indicates the desired state. Cypress’s guidance on interacting with elements explains waiting on actionable application conditions rather than treating elapsed time as proof of readiness.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

The example using cy.get(...).should('be.visible') waits on a condition. A fixed delay, by contrast, only waits a duration: on a fast run it wastes time, and on a slow run it may still be too short. If a request is the meaningful readiness signal, wait for that request; if the application exposes a ready marker, assert against it.

Also avoid branching on incidental DOM timing, such as checking whether a banner happens to exist at one instant and taking a different path based on that observation. Cypress’s conditional-testing guide cautions against decisions based on unstable DOM state. Make the state deterministic through the cookie or real request contract, then wait for its observable result.

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

Troubleshoot common failures

The banner still appears after setting a cookie

  • Confirm the cookie name and value against the application’s actual consent implementation; the sample values are not standard Cypress values.
  • Ensure cy.setCookie() runs before cy.visit(), not after the app has already evaluated consent.
  • Check whether the app requires additional state or uses a request to decide banner visibility. If so, use the real app behavior rather than assuming one cookie is sufficient.
  • Wait for an application state signal before diagnosing the screenshot; a banner observed mid-render may not reflect the settled state.

The banner is visible in the image despite blackout

  • Check that the selector matches the banner element in the page being captured.
  • Confirm the screenshot invocation is a cy.screenshot() capture mode to which blackout applies; it does not apply to runner captures.
  • Verify that the capture occurs after the page has rendered the selected element. A selector that appears later cannot reliably identify the intended region at an earlier capture point.

The intercept never sees the consent request

  • Register the intercept before navigation and make sure its matcher reflects the request the application actually makes.
  • Check whether the browser served the response from cache. Cached responses do not pass through the network layer and cannot be intercepted there.
  • Do not infer a consent endpoint from a generic example: inspect the application’s network contract and use its real route and response.

The screenshot varies between runs

  • Replace arbitrary delays with a visible ready marker, app-set state indicator, or completion of the relevant request.
  • Make the consent state deterministic before navigation rather than branching on whether a banner happens to be in the DOM.
  • Keep the capture aligned with the test purpose: a functional consent test should exercise consent; a visual-only capture can use blackout.

Or skip the browser setup

If you need a clean screenshot outside a Cypress test, ScreenshotNeo can return an image or PDF from one GET request. Its documented options include PNG, JPEG or WebP output, and PDF settings; consult the ScreenshotNeo API documentation for request options.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month with no card.

Keep the test honest about what it proves

Use the cookie route when the page should genuinely behave as if consent has been saved. Use blackout when only the captured pixels should omit a banner and the test is not validating consent. Use an intercept when a real request defines the state and your fixture faithfully represents it. Then synchronize on the app’s settled state so the screenshot records the intended result rather than a timing accident.

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

Frequently Asked Questions

Does Cypress have a built-in option that dismisses every cookie banner?

The documented approaches here are application-specific: seed the app’s known consent cookie, stub a genuine state-setting request, or use screenshot blackout for a visual-only capture. They do not amount to a universal banner-dismissal switch.

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.

Can I use the same consent cookie value on every website?

No. The cookie name and accepted value are defined by each application.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

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.