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
World desk3 min

How to Fix Playwright Screenshots That Include a Scrollbar

Use Playwright’s screenshot-time CSS to hide a scrollbar, or choose the right capture scope when you need a scrollbar or nested panel included.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To remove an unwanted scrollbar from a Playwright screenshot, use the screenshot API’s style option to apply temporary CSS to the element that actually scrolls. This keeps the change out of your app’s permanent styles. If a scrollbar is missing and you want it included, first check whether you are capturing the viewport, the full document, or a nested scrolling element—fullPage does not expand nested scroll containers.

Hide an unwanted scrollbar in the screenshot

Playwright’s Page screenshot API accepts a style string. Playwright applies that stylesheet while rendering the screenshot, so you can scope a scrollbar-hiding rule to the page or panel that owns the scroll without changing the application’s normal stylesheet.

Start by identifying the scroll owner. Page-level scrolling is associated with the document root; a panel may scroll independently through its own overflow styling. Apply a CSS rule that hides the scrollbar for the relevant element, then capture:

await page.screenshot({
  path: 'screenshot.png',
  style: `
    /* Replace this with a scrollbar-hiding rule for the actual scroll owner. */
  `,
});

The placeholder is deliberate: the correct selector and CSS depend on the page, browser, and scrolling element. There is no single unscoped rule established here as a universal cross-browser fix. Verify the rule against your target browser and the element that scrolls.

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

Keep the style limited to the screenshot

Using style avoids adding a screenshot-only rule to your production CSS. If the screenshot still shows a bar, check that your selector matches the scrolling element and that the element is the one with the scrollbar; hiding a bar on the document root will not necessarily affect a nested panel.

If the scrollbar is missing but you want it

Confirm the capture scope before changing CSS. Playwright’s fullPage screenshot option captures the document’s scrollable content; it does not take a sequence of ordinary viewport screenshots, nor does it expand every independently scrollable panel. The option defaults to false. See the screenshot API documentation.

  • Viewport capture: captures the currently visible page area. A scrollbar may depend on the browser and operating-system rendering environment.
  • Full-page capture: captures the document’s scrollable content. It does not expand a nested scroll container.
  • Element capture: targets a particular element. For a nested scrolling panel, capture the container itself and check whether the visible portion or the content you need is represented in the result.

Playwright collaborator Dgozman summarized the nested-container distinction in a response to issue #12962 on March 24, 2022: “The behavior you describe is expected. Full page screenshots do not expand any scrollable container in the page. Instead, they render the full scrollable content of the document itself.” Issue #12962.

Troubleshoot by capture scope and environment

  • The bar remains after adding screenshot CSS: inspect the page to identify which element scrolls, then scope the rule to that element. A nested panel and the document may need different selectors.
  • A full-page image omits the scrollbar: full-page capture represents document content, not necessarily a visible scrollbar in the rendered output. A report against Playwright 1.50.1 on Windows 11 describes this outcome; it is an environment-specific report, not a universal guarantee. Issue #35328.
  • A nested panel is cut off: capture the panel element rather than expecting fullPage: true to expand it. The full-page option applies to the document’s scrollable content.
  • A launch flag appears ineffective: issue reports include attempts to change the --hide-scrollbars argument, but they do not establish it as a reliable switch across screenshot modes. Prefer the documented screenshot-time style option when you need to hide a bar, and verify behavior in your browser and OS. Issue #35328 and Issue #12962.

When diagnosing a difference between local and CI screenshots, record the Playwright version, browser, operating system, capture type, and scroll owner. Scrollbar rendering and screenshot behavior should not be generalized from one reported environment to every setup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup: use ScreenshotNeo

If you need a website screenshot without configuring Playwright, ScreenshotNeo provides a screenshot API. One GET request returns an image or PDF; for this example, request a screenshot of the page you want to 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 ScreenshotNeo API documentation for request options. Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; these steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

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.

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

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.