puppeteer: Chrome extension is not loaded on headless browser

running scenario with headless:true cause configured extension not to load.

browser = await puppeteer.launch({headless:false,args:[
'--load-extension=/Path/to/extension'
], ignoreHTTPSErrors:true});

With the same code running with headless:false - the extension is loaded as expected.

Is there any limitation with chrome extension loading on headless browser?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 34
  • Comments: 41 (4 by maintainers)

Most upvoted comments

Chrome Headless doesn’t support extensions.

@vitalets in the meantime you can use --disable-extensions-except to enable only the extensions that you want to test:

var options = {
  headless: false,
  args: [
    '--disable-extensions-except=/path/to/extension/',
    '--load-extension=/path/to/extension/',
  ]
}

@aslushnikov any chance to get this feature in the future? It would be awesome for testing extensions!

Any news?

In the meantime we are starting an xvfb server:

xvfb-run node test.js

For loading multiple chrome extensions, you can pass a comma-seperated list;

var options = {
  headless: false,
  args: [
    '--disable-extensions-except=/path/to/ext1/, /path/to/ext2/, /path/to/ext3/'
  ]
}

Also, i’ve found that in Version 67 at least, the --load-extension flag isn’t needed, but in any case this flag will also accept a comma-seperated list.

Any Update?? Thanks…

Any news?

Chrome Headless doesn’t support extensions.

For anyone stumbling on this by searching for how to load extensions in headless Chrome, here’s more info about the decision to not (yet) support extensions in headless Chrome.

So Puppeteer really not going to support the Google Chrome extension? If that’s the case, it’s disappointing! 😞

any news?

It is definitely possible to run extensions with headless set to “new” I did it with Chrome 120

My question is about the use of extensions in the chrome web store, can i use extensions of this site? thanks

@vitalets in the meantime you can use --disable-extensions-except to enable only the extensions that you want to test:

var options = {
  headless: false,
  args: [
    '--disable-extensions-except=/path/to/extension/',
    '--load-extension=/path/to/extension/',
  ]
}

What is the path to extension for windows box

Ok. Anyway after https://github.com/GoogleChrome/puppeteer/pull/774 extensions do not work even with headless: false option, so waiting for https://github.com/GoogleChrome/puppeteer/issues/872 to be shipped.

any chance to get this feature in the future?

@vitalets I’m not aware of any plans.

I finally got it running using xvfb right in JS, restarting it each time before I create a puppeteer browser. Had serious permission issues when not running it on root, so I switchted back to root and fixed the permissions after the docker run. Now it works pretty flawlessly but it was a big headache. Maybe I’ll write a blog article about it.

What’s the current state of the art for testing with extensions then?

I’m using headless:false mode for testing extensions.

Please write a blog. 🙏

I’m using xvfb, but the extension isn’t running. Wondering if anyone can help a guy out over here?

Okay, the solution for running headless false to load extensions is xvfb. My question is: how can i run 3 browsers in parallel with one xvfb process?

What’s the current state of the art for testing with extensions then?