The following example exposes defaultArgs for the Chrome and Firefox Launcher via undocumented api's and uses the documented ignoreDefaultArgs: true option to supply fully costumized args: [] containing the defaults for the given browser launcher
import
import Puppeteer from 'puppeteer';
in case of firefox inside docker set product before running the next part: is not needed if you started Puppeteer with a Environment var
Puppeteer._productName = 'firefox'
finaly launch
Puppeteer.launch({
// product: 'firefox', // if you want to use firefox do not forget the above
ignoreDefaultArgs: true, // use only our supplyed args: []
executablePath: '/usr/bin/docker', // we want to run docker right?
args: [
// docker arguments
'run',
'-p=9333:9333',
'-p=3000:3000',
'-it',
`${dockerImage}`,
`/usr/bin/google-chrome`,
// end docker arguments
...Puppeteer._launcher.defaultArgs({
devtools: false, // devtools auto open needs headless false
headless: true, // needs to be false if devtools auto open
userDataDir // needs to get set here no where else is optional
}),
// Here comes what you would put into args in general
],
pipe: true
}
Puppeteer._launcher is a getter that looks up _productName and returns the correct launcher which holds the defaultArgs Method.
_productName also gets set on Puppeteer.launch({ product: 'chrome'}) to the value of product
we avoid calling the internal Puppeteer._launcher.defaultArgs(options) call with the ignoreDefaultArgs: true option as we can filter the output our self if needed as we call it our self