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.

[Bug] puppeteer stealth mode is not working with browser.pages

See original GitHub issue

Stealth mode is not working with array of pages

I am using stealth mode in chrome headful and its working but when I change to headless the stealth mode didn’t work with it, I have figured the problem because I using array of pages and I have to use this in that way for other isseues with bot detection.


const puppeteer = require('puppeteer-extra')
const StealthPlugin = require('puppeteer-extra-plugin-stealth')

puppeteer.use(StealthPlugin())

;(async () => {
  const browser = await puppeteer.launch({
  headless: true,
  executablePath: '/path/to/Chrome'
  })
  const [ page ] = await browser.pages()
  await page.goto('https://bot.sannysoft.com')
  await page.waitForTimeout(5000)
  await page.screenshot({ path: 'testresult.png', fullPage: true })
  await browser.close()
})()

Versions puppeteer-extra@3.1.18 puppeteer-extra-plugin-user-preferences@2.2.12

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

1reaction
GiveDaDatacommented, Jun 9, 2021

I think the default page does not have plugin enabled

let page = await browser.newPage(); let pages = await browser.pages(); const oldPage = pages[0]; oldPage.close(); I do this to have only one page, but const page = await browser.newPage(); should be fine for headless

0reactions
robintancommented, Jun 11, 2021

Since we the headless stealth is not working on default page, i.e. const page = (await browser.pages())[0], we cannot use the incognito page actually, since browser.newPage() opens up a new page in a non-incognito context

const browser = await puppeteer.launch({
  headless: true,
  args: [
    '--no-sandbox',
    '--incognito',
  ]
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the puppeteer-extra.launch function in ... - Snyk
To help you get started, we've selected a few puppeteer-extra examples, based on popular ways it is used in public projects. Secure your...
Read more >
Download not working on Stealth Plugin with used with ...
The problem: Once the button is clicked, nothing happens, no download is initiated. Basically, removing puppeteer.use(StealthPlugin()) makes the ...
Read more >
puppeteer-extra-plugin-stealth - npm
Stealth mode : Applies various techniques to make detection of headless puppeteer harder.. Latest version: 2.11.1, last published: 5 months ...
Read more >
Troubleshooting - Puppeteer
The most common cause is a bug in Node.js v14.0.0 which broke extract-zip , the module Puppeteer uses to extract browser downloads into...
Read more >
Avoid being blocked with puppeteer - Cobalt Intelligence
One of the main questions I see on forums and reddit with regards to web scraping is…”how do I avoid being blocked?”. This...
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