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.

Different behavior between { headless: false } and { headless: true }

See original GitHub issue

I’m curious to know what changes there are between running as headless true vs false. When I run a login to Amazon using headless: true I get an error from Amazon via the screenshot. But when I set headless: false I watch it work just fine, no error.

So I’m trying to figure out what headless: true is doing that is different from when it’s not headless.

Thanks to any suggestions.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:78
  • Comments:53 (7 by maintainers)

github_iconTop GitHub Comments

71reactions
koreus7commented, Jan 10, 2018

As mentioned in the article @Garbee posted the headless version does not have languages set on the navigator object.

Note also that the headless version will not have languages set in its Accept-Language Header. Some sites (ASP.NET in my experience) require this header to be set. Other sites are looking for this header specifically to identify headless browsers.

I copied the value from an example request generated by my normal chrome install. There is probably a more minimal setting for this header that works.

await page.setExtraHTTPHeaders({
    'Accept-Language': 'en-GB,en-US;q=0.9,en;q=0.8'
});
63reactions
jondlmcommented, Jun 7, 2018

For what it’s worth I’ve also found that adding the following user agents override can help smooth over differences in some cases:

await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36')

The UA I’ve provided is just an example. You can use any valid UA that matches an existing browser.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does headless need to be false for Puppeteer to work?
The reason it might work in UI mode but not headless is that sites who aggressively fight scraping will detect that you are...
Read more >
The Java Headless Mode - Baeldung
If the environment is actually headless, the JVM would be aware of it implicitly. However, there will be subtle differences in some ......
Read more >
Puppeteer - Non Headless Execution - Tutorialspoint
By default, Puppeteer executes the test in headless Chromium. This means if we are running a test using Puppeteer, then we won't be...
Read more >
Detecting Headless Chrome: Puppeteer-Extra-Plugin-Stealth
Under the hood, headless browsers behave just like other browsers. ... to distinguish between a genuine Chrome browser used by humans and ...
Read more >
pyppeteer headless=false - Unisa
The headless browser will behave as a 'normal' user and scrolls to the bottom of ... Different behavior between { headless: false }...
Read more >

github_iconTop Related Medium Post

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