Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
FREEDOM251

Freedom251 › Blog › browser automation

How to Screenshot an Indian News Website with Playwright When Ads Shift the Layout

By Freedom251 Team · · 6 min read

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.

Wait for the article content you actually need—not for the whole network to go quiet—then capture the intended page state. Playwright’s load event does not ensure that later ads and widgets have finished changing the layout, and Playwright discourages networkidle as a testing readiness signal. The reliable approach is to define whether ads belong in the image, wait for a meaningful page condition, and use a full-page or element screenshot accordingly.

Choose what the screenshot should show

Before writing a wait condition, decide whether this is an archival image of the page as a visitor sees it or a repeatable check of the article’s editorial layout. Those goals call for different handling of ads and other dynamic regions.

As an Amazon Associate I earn from qualifying purchases.

  • Visitor-view capture: preserve ads, notices, and widgets. Wait for the relevant content or layout to reach the state you want to record. A fixed delay can give asynchronous content more time, but it cannot guarantee that third-party ads have settled.
  • Editorial-layout check: if ads are intentionally outside the test’s scope, hide or mask the relevant region using a documented stylesheet or screenshot mask. Do this only when removing it matches the purpose of the capture.

There is no single selector or ad behavior that applies to every Indian news publisher. Use selectors specific to the article and site you are capturing, and check the publisher’s current terms and robots policy before repeated automated captures.

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

Set up a Playwright capture

The example below uses Playwright Test so it can assert that the article is present before capturing it. Replace the example URL and article locator with values appropriate to the selected page. Install Playwright Test and its browser dependencies for your environment as described in the official Playwright getting-started guide.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • 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
import { test, expect } from '@playwright/test';

test('capture a news article', async ({ page }) => {
  await page.goto('https://example.com/news/article', { waitUntil: 'domcontentloaded' });

  const article = page.locator('article');
  await expect(article).toBeVisible();
  await expect(article).toContainText(/S/);

  // For an archival capture, leave ads and other page content visible.
  await page.screenshot({ path: 'article.png', fullPage: true });
});

domcontentloaded is only a navigation milestone, not proof that all meaningful content has arrived. The assertions make the capture wait for an observable article state; adjust them if the site uses a different structure or loads article content in stages.

Wait for the intended layout, not network silence

Modern pages may fetch data lazily and populate interface elements after navigation. Playwright’s navigation guidance notes that there is no universal way to tell when a page is “loaded”; readiness depends on the page and framework. The Page API defines networkidle as no network connections for at least 500 ms, but marks it discouraged for testing and recommends web assertions instead. Ads can make network activity intermittent, while a quiet network does not prove that the visual state you need is ready.

If the screenshot should include ads

Wait for a site-specific condition that represents the ad state you want—such as an ad slot becoming visible or a known layout container reaching its expected state—then capture. Do not assume that a generic ad selector or a short timeout works across publishers. Third-party ad content can arrive late or resize after appearing, so even a targeted wait cannot guarantee identical creative or timing in separate sessions.

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 | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • 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

If ads should not affect the test

Use a screenshot style or mask for the volatile area only if the purpose is to compare the article layout without ads. Playwright Test screenshot assertions support a style option for applying CSS during capture and a mask option for covering matching locators. A mask stabilizes the appearance of a region; it does not prevent the page from shifting because that region was inserted or resized. If the shift itself affects the layout under test, address that explicitly rather than treating masking as a fix.

await expect(page).toHaveScreenshot('article.png', {
  fullPage: true,
  animations: 'disabled',
  mask: [page.locator('.ad-slot')],
});

Replace .ad-slot with a selector verified on the chosen page. For details and version-specific options, see the Playwright screenshot testing documentation.

Capture a full page or just the article

Full-page screenshot

For a single image of the scrollable page, use fullPage: true. This captures the full page height and can produce a very tall image. If the image is unwieldy or the goal concerns only the story, capture the article element instead.

Rank #3
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.
await page.screenshot({ path: 'article-full.png', fullPage: true });

Article-only screenshot

A locator screenshot captures one element rather than the entire page. It is useful when ads, recommendations, or navigation outside the article are not part of the desired image.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.locator('article').screenshot({ path: 'article-only.png' });

Element screenshots depend on a correct locator and a visible element. Check the page’s actual markup rather than assuming every publisher uses the same article element.

Make visual comparisons more repeatable

For regression checks, expect(page).toHaveScreenshot(...) waits until two consecutive screenshots match before comparing against the expected image. That helps with transient changes, but it does not make a third-party ad serve the same content in different sessions.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • 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

Keep the rendering environment consistent between baseline and later captures: browser and version, operating system, viewport, device scale, locale, and relevant settings. Playwright notes that screenshots can vary with the host OS, browser version, settings, hardware, power source, and headless mode.

By default, screenshot dimensions reflect device scale. Use scale: 'css' when you want one image pixel per CSS pixel rather than device-pixel output, which can be larger on high-DPI displays.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.screenshot({
  path: 'article-css-pixels.png',
  fullPage: true,
  scale: 'css',
});
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why news-page layouts shift

A screenshot can change after navigation because the page inserts or resizes content as resources arrive. Documented sources of unexpected layout shifts include images or videos without known dimensions, font changes, and third-party ads or widgets that resize themselves. A cookie notice or ad can also appear after the load event and move content.

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.

If you operate the site, reserving space for expected ad or banner sizes, or positioning a notice outside normal document flow, can limit shifts. If you are capturing someone else’s site, identify the target state and use a condition, style, or mask suited to the capture’s purpose; do not assume the page will stop changing at a fixed time.

Troubleshooting

  • The screenshot misses the article text. The page may populate content after the navigation event. Assert that the relevant article locator is visible and contains expected text before capturing.
  • The page keeps changing after the screenshot. Ads or widgets may load or resize asynchronously. Decide whether they belong in the image; if they do, wait for a site-specific state. If they do not, consider a targeted style or mask where appropriate.
  • networkidle never arrives or gives inconsistent results. Ads and other third-party requests may continue or restart. Use an assertion tied to the content or state that matters instead.
  • The full-page file is too tall or hard to use. Capture the article locator rather than the complete page, or choose a suitable crop for the use case.
  • Visual tests fail across machines despite no intended page change. Compare browser, OS, viewport, device scale, locale, and execution settings; screenshot output can vary with the rendering environment.
  • A mask hides an ad but the article still moves. Masking changes what appears in the screenshot, not how the page lays itself out. If the ad’s insertion shifts the article, the capture must account for that shift or the test must deliberately exclude the affected layout.

Or skip the browser setup

ScreenshotNeo can return a screenshot or PDF with one GET request. For example, this cURL call saves a WebP screenshot of an article URL; create an API key and replace the URL with the page you want to capture. See the ScreenshotNeo API documentation for request options.

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

ScreenshotNeo accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks and 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 screenshot, page-information, and PDF-capture tools for AI agents. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000.

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

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Frequently Asked Questions

Can I make ads appear identically in screenshots from different sessions?

No. A screenshot assertion can wait for two matching consecutive captures within a run, but it cannot ensure a third-party ad serves the same content or timing across sessions.

Does a full-page screenshot include only what is visible in the viewport?

No. Playwright’s full-page screenshot captures the full scrollable page; use a locator screenshot when you need only the article element.

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.

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

browser automationPlaywrightvisual testingweb screenshots

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.

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

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.