20 Aug 2025 | 5 min read
Capturing clean and professional screenshot on websites is a critical activity for developers, marketers and QA team as well as content creators. Being able to take a clear screenshot may be important whether it is targeted to visual testing, marketing materials, or tracking of changes on the web sites.
But there's one common issue: cookie banners.
These banners that seem to be applied mainly as a GDPR compliance appear on practically every web page. It is also capable of obscuring significant elements on a page, especially when the user agent is not properly configured, causing the screenshot to appear sloppy or unfinished.
In this blog, we’ll explore:
Let’s start by understanding what cookie banners are and why they can be a problem in screenshots.
A cookie banner is a small message that appears on many websites when you visit them. It normally requests you to accept cookies which are tiny files designed to keep track of your visit. Most countries have privacy regulations such as GDPR that require the use of these banners.
Although cookie banners should be taken seriously in relation to the privacy of the user, they may pose some issues in becoming a challenge when trying to take a screenshot of a particular webpage.
Because of these reasons, many people want to hide or remove cookie banners automatically when taking screenshots.
Puppeteer is a free and open-source Node.js library made by Google. It allows developers to control a browser (like Chrome or Chromium) through code.
With Puppeteer, you can do things like:
It’s a powerful tool, mostly used for testing websites, scraping data, or automating browser tasks.
To hide a cookie banner with Puppeteer, we need to do the following:
Here's an actual working example:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Go to the website
await page.goto('https://example.com', { waitUntil: 'networkidle2' });
// Wait a bit in case the cookie banner loads late
await page.waitForTimeout(2000);
// Hide the cookie banner using its CSS class or ID
await page.evaluate(() => {
const banner = document.querySelector('.cookie-banner'); // Replace with the correct selector
if (banner) {
banner.style.display = 'none';
}
});
// Take a screenshot after hiding the banner
await page.screenshot({ path: 'screenshot.png', fullPage: true });
await browser.close();
})();
Note: You must know the correct CSS selector (like .cookie-banner or #cookiePopup) used by the website you are working with. It changes from site to site.
While Puppeteer gives you full control, it also comes with some challenges:
That’s why many people look for an easier option, especially if they want to take screenshots at scale.
ScreenshotAPI.net is a cloud-based tool that lets you capture screenshots of websites just by making a simple API call. It works without any setup, even when dealing with lazy loaded images, no need to install a browser, write code, or manage servers.
With ScreenshotAPI.net, you can:
It’s designed to be fast, scalable, and easy to use even for non-developers.
Hiding cookie banners with ScreenshotAPI.net is very simple. All you need is the CSS selector of the element you want to remove, and you pass it as a parameter called remove_selector in your API request.
Here’s an example:
https://shot.screenshotapi.net/screenshot
?token=YOUR_API_TOKEN
&url=https://example.com
&no_cookie_banners=true
&output=image
&file_type=png
&full_page=true
Here’s why ScreenshotAPI.net is easier than using Puppeteer for this task:
In short, ScreenshotAPI.net makes hiding cookie banners and capturing clean screenshots simple and accessible to everyone, even if you're not a developer.
Cookie banners are everywhere and, although they fulfil a valuable purpose in the legal requirements, they become annoying when you want clean, clear screenshots of a webpage, especially in headless mode.
In this blog, we demonstrated to you how to block cookie banners by using Puppeteer which is a powerful browser automation library. Puppeteer allows you to have complete control, including using the evaluate function, but you need to know how to code, have time to set it up as well as technical know how.
We also explored ScreenshotAPI.net, a simple but a powerful alternative which only requires you to add a parameter to the request, or generate a new file, one single parameter and cookie banners vanish, no configuration, no code.
You can hide them using custom CSS or browser automation tools like Puppeteer or ScreenshotAPI by targeting their CSS selectors or just passing no_cookie_banners=true.
Yes, Puppeteer can take screenshots of any web page, including full-page or specific sections.
Use page.deleteCookie() or context.clearCookies() in your Puppeteer script to remove cookies.
You can write a script to find and remove the popup using Puppeteer, or use ScreenshotAPI’s remove_selector option to hide it automatically.