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.

Playwright Python can return different HTML in headed and headless runs because the two runs may use different Chromium executables, channels, context settings, environments, or capture times. The Python binding is rarely the cause by itself. Playwright supplies a regular Chromium build for headed operation and, by default, a separate headless Chromium shell. The chromium channel selects a newer headless implementation that is closer to the regular browser. Before changing selectors or application code, make the browser binary, version, context, environment, network state, and readiness condition identical.

What page.content() is actually returning

page.content() serializes the document that exists when you call it, including the doctype. It is not a promise that the application has reached its final visual or data state. A server response can be identical while JavaScript later hydrates a framework, inserts API data, switches a client-side route, loads lazy content, or changes markup after fonts and scripts become available.

Consequently, a headed run that happens to capture after hydration can differ from a faster headless run captured at DOMContentLoaded. Conversely, a headless run can expose a failed request or missing browser dependency that a headed run masks through different timing.

The main causes of headed/headless HTML divergence

1. Different Chromium implementations

Playwright documents a regular Chromium build for headed operation and a separate Chromium headless shell for default headless operation. Branded channels such as Chrome and Edge are separate choices. Their newer headless implementation uses the real browser more closely than the older shell. Thus headless=True and headless=False are not automatically testing the same executable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
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

Binary parity is the first comparison. Record the browser type, channel, executable path, Playwright package version, and browser version in both environments. If parity is required, install the same Playwright version and intended browser artifacts, or explicitly test the newer headless implementation through the chromium channel.

2. Viewport and device emulation

A new context defaults to a 1280×720 viewport unless you configure it. Headed windows can be resized when no_viewport is used, while headless contexts commonly retain the fixed context viewport. Responsive templates may therefore render different navigation, tables, or components.

Normalize the complete emulation profile: viewport, screen, device_scale_factor, is_mobile, has_touch, user agent, locale, and timezone. A viewport mismatch alone can cause different server-side markup or client-side breakpoint branches.

3. User, locale, and feature-detection inputs

Applications can branch on user agent, locale, timezone, JavaScript availability, permissions, proxy responses, media capabilities, and installed fonts. Cookies, authentication, storage state, and request interception can also change the data that is serialized. GPU availability and operating-system libraries are especially relevant when local headed execution and a Linux CI container are being compared.

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

4. Navigation and asynchronous timing

Playwright exposes navigation milestones such as commit, domcontentloaded, load, and networkidle. None means “the application will never mutate the DOM again.” Single-page applications frequently continue fetching and hydrating after those milestones. Prefer a deterministic application signal—a visible dashboard, a known data attribute, or a completed API response—rather than an arbitrary sleep. Playwright discourages relying on networkidle as a general test strategy because ongoing analytics, sockets, and polling can make it unreliable.

5. Version and environment drift

Playwright browser binaries are versioned with the library, while branded Chrome or Edge channels are independently selected. A local headed run might use a branded channel and CI might use the bundled headless shell. Different fonts, sandbox permissions, shared libraries, proxy settings, and environment variables can produce different responses or feature detection even with the same URL.

Build a controlled Python comparison

Run the following script twice, changing only headless. Use the same Playwright package, browser channel, machine image, credentials, proxy, and network mocks. Replace the test URL and readiness test with values from your application.

from playwright.sync_api import sync_playwright

URL = "https://example.test"

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)  # repeat with False
    context = browser.new_context(
        viewport={"width": 1280, "height": 720},
        locale="en-US",
        timezone_id="UTC",
        java_script_enabled=True,
    )
    page = context.new_page()
    page.goto(URL, wait_until="domcontentloaded")
    page.get_by_test_id("app-ready").wait_for(state="visible")
    html = page.content()
    print({
        "url": page.url,
        "user_agent": page.evaluate("navigator.userAgent"),
        "viewport": page.viewport_size,
        "html_length": len(html),
    })
    browser.close()

The readiness locator must represent a real application condition. If your page has no test id, wait for a stable heading, a data attribute, or a response that your application owns. Do not replace that condition with wait_for_timeout(); fixed delays become flaky as CI load and network latency change.

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.
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.

Make the two runs genuinely comparable

  1. Pin software. Use the same Playwright Python version and install the same browser revision in local and CI environments. State whether a branded channel or bundled Chromium is used.
  2. Normalize the context. Set an explicit viewport, user agent, locale, timezone, JavaScript setting, permissions, proxy, and device options. Reuse the same cookies, authentication state, and storage state.
  3. Control the network. Use identical request routing, API mocks, headers, cache policy, and credentials. A different response is a data difference, not a headless rendering defect.
  4. Use one readiness assertion. Capture only after the same application-specific element or state is present. Keep the assertion in both headed and headless paths.
  5. Log the inputs. Record the final URL, browser type and version, channel, user agent, viewport, locale, timezone, launch arguments, and relevant environment details.
  6. Compare meaningful output. Normalize known dynamic values such as timestamps, request IDs, random IDs, rotating ads, and session tokens before diffing. Preserve a raw copy as well so that normalization cannot hide a real defect.

Separate server HTML, client HTML, and rendering problems

Compare the raw response

Save the response body obtained before JavaScript runs and compare it between configurations. If it differs, investigate user-agent negotiation, cookies, locale, authentication, proxy behavior, cache, or server-side feature flags. If it matches but page.content() differs, the mutation occurred in the browser after navigation.

Inspect browser diagnostics

Attach listeners for console messages, uncaught page errors, and failed requests. Capture a screenshot at the same readiness point. A missing script, blocked API call, CORS failure, or JavaScript exception often explains why an element exists in one mode but not the other.

page.on("console", lambda msg: print("console:", msg.type, msg.text))
page.on("pageerror", lambda exc: print("page error:", exc))
page.on("requestfailed", lambda req: print("request failed:", req.url, req.failure))
page.screenshot(path="comparison.png", full_page=True)

Test the newer headless implementation

When the suspected variable is the headless binary, run an otherwise identical case with the chromium channel and document that choice. This does not prove that every site will match headed output; it tells you whether the headless shell was the differentiator.

Why headed success does not prove CI parity

A visible window confirms only that one particular environment produced the expected result. It does not prove equal browser channels, OS libraries, fonts, GPU access, viewport, network timing, or storage state. CI should be treated as a separate environment until those axes are logged and aligned. If a failure appears only in CI, first reproduce it with the same container image and launch configuration in headed mode, then compare diagnostics rather than assuming “headless is broken.”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

Common symptoms and fixes

Symptom Likely cause Fix
Markup changes immediately when headless=False is added Different executable, channel, or browser revision Print browser/channel/version information; pin the package and browser; test the chromium channel.
Element is present headed but missing headless Responsive viewport, user-agent branch, failed request, or capture before hydration Set an explicit viewport and user agent, inspect failed requests, and wait for an application-specific ready assertion.
Only localized text or date markup differs Locale or timezone mismatch Set identical locale and timezone_id; compare cookies and server headers.
HTML length changes between runs Dynamic IDs, ads, timestamps, random data, or asynchronous API results Capture at the same readiness point and normalize documented dynamic fields before diffing.
Headless fails in CI but local headed works Missing OS libraries/fonts, sandbox restrictions, proxy differences, or JavaScript errors Use the supported CI image, collect page errors and request failures, and compare environment and launch settings.
networkidle never arrives Analytics, polling, WebSockets, or long-lived connections Wait for a specific DOM assertion or controlled API response instead of global network idle.

Performance, reliability, and test design

  • Use a fixed viewport and deterministic data when the purpose is HTML comparison; this removes accidental breakpoint and content variation.
  • Keep headed mode for inspection and debugging, not as evidence that production CI will behave identically.
  • Pin browser artifacts and refresh them deliberately with dependency updates. Unplanned browser drift can look like an application regression.
  • Prefer semantic assertions over full-string HTML equality. Full snapshots are sensitive to harmless attribute order, generated IDs, timestamps, and third-party widgets.
  • When exact serialization is required, define a normalization policy and fail on unexpected differences after normalization.
  • Do not infer a universal divergence rate. Authoritative Playwright documentation explains the mechanisms but does not publish a frequency statistic.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a clean screenshot or PDF rather than diagnosing DOM parity, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP, or PDF. It accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled.

Only clean shots are billed. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and each response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

Use the API documentation at https://screenshotneo.com/docs/ for authentication and options. A minimal cURL request is:

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

The equivalent Python call is:

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)

And 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 includes full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets or any viewport, retina scale, PDF paper size and page ranges, HTML/CSS-to-image, custom CSS and JavaScript, click-before-capture, selector hiding, waits for selectors or network conditions, blocking for ads, trackers, requests, or resource types, custom headers/cookies/user agents/Authorization, timezone and geolocation, transparent backgrounds, resizing, selectable cache TTL, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, an OpenAPI specification, and compatibility with parameter names used by other screenshot APIs.

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

Plans are Free (1,000 shots per month, no card), Starter ($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 provides two months free, and every feature is on every plan. Sign up free for 1,000 screenshots a month with no card.

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.

FAQ

Is the Python binding responsible for the difference?

Usually not. Python calls the same Playwright browser protocol; executable selection, context values, environment, network responses, and timing are more common causes.

Can I compare only the DOM and ignore pixels?

Yes. Compare normalized page.content() strings for structure, and use screenshots separately when layout, fonts, or rendering is the suspected issue.

Should I always use networkidle before reading HTML?

No. Persistent connections can prevent it or make it misleading. A stable application assertion is generally a better readiness boundary.

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

Does selecting the chromium channel guarantee identical output?

No. It addresses one binary choice. Viewport, locale, data, operating system, fonts, permissions, and capture timing can still differ.

Frequently Asked Questions

What is the fastest first check when headed and headless HTML differ?

Verify the browser executable or channel, Playwright version, viewport, user agent, locale, timezone, and readiness assertion before changing application code.

Why does a fixed sleep not reliably solve the mismatch?

A fixed delay does not represent application readiness and varies with CI load and network latency; wait for a deterministic DOM or API condition instead.

How can I tell whether the server or browser changed the HTML?

Compare the raw response body before JavaScript with post-navigation page.content(). A difference in the raw response indicates server, request, or state variation; a later difference indicates client-side mutation.

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

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.