question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Headless mode should not force --hide-scrollbars

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.17.0
  • Platform / OS version: macOS / CI (linux)
  • Node.js version: 10.16.0

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. Create a page with a block level element and measure its width
  2. Increase the element height so the page shows the scrollbars
  3. Measure the element’s width again

What is the expected result?

The element’s width differs because the scrollbar makes it shrink

What happens instead?

The element’s width doesn’t change. This is because Puppeteer in headless modes hides the scrollbars. https://github.com/GoogleChrome/puppeteer/blob/f5bb333cd0c42306f47e7767e5cb8b78af557c27/lib/Launcher.js#L85

AFAIK at the moment there is no way to override this behavior.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:9
  • Comments:7

github_iconTop GitHub Comments

8reactions
karlcommented, Aug 1, 2019

With a bit of Googling I found out you can override the default behaviour so you do see scrollbars in headless mode. Just add ignoreDefaultArgs: ["--hide-scrollbars"] to your puppeteer configuration:

this.browser = await puppeteer.launch({
  // Existing config goes here...
  ignoreDefaultArgs: ["--hide-scrollbars"]
});

Code copied from here: https://github.com/GoogleChrome/puppeteer/issues/2999#issuecomment-490854398

4reactions
ThibaultJanBeyercommented, Nov 22, 2020

+1 the default set-up should be the same as a non-headless mode = i.e. either display the scrollbars or hide the scrollbars on both. But currently, headless: true, will hide scrollbars while headless: false will show scrollbars. Giving different test results based on wether it’s headless or not.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chrome headless puppeteer: make screenshot render scrollbar
Headless mode should not force --hide-scrollbars. The quick solution to ensure that scrollbars were rendered, both on our CI with headless ...
Read more >
Using CSS to hide scrollbars without impacting scrolling
This guide will show you how to hide the scrollbar in several popular ... While it's common practice not to mess with default...
Read more >
Getting Started with Headless Chrome - Chrome Developers
A headless browser is a great tool for automated testing and server environments where you don't need a visible UI shell. For example,...
Read more >
How To Hide Scrollbars With CSS - W3Schools
It is not possible to scroll inside the page. Tip: To learn more about the overflow property, go to our CSS Overflow Tutorial...
Read more >
hide-scrollbars doesn't work anymore after Target.createTarget
1. run chrome with "--headless --no-sandbox --disable-gpu ... b) --hide-scrollbars should set the default value of the hide_scrollbars ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found