Get command line flags of launched Puppeteer instance programmatically

Viewed 281

I'm launching a Puppeteer instance that I would like to get some info of which flags this instance was launched with. For example, the --user-data-dir flag since sometimes I would like to use the same Puppeteer profile that would store cookies and login info.

Is there a way to fetch the values visible at chrome://version programmatically?

const puppeteer = require('puppeteer');

(async () => {
const browserURL = 'http://127.0.0.1:9222';
browser = await puppeteer.connect({browserURL,defaultViewport : null });
page = await browser.newPage();
})();
2 Answers

Try this:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  console.log(browser.process().spawnargs);
  await browser.close();
})();

UPD. For connected browser:

  await page.goto('chrome://version');
  const tableCell = await page.waitForSelector('#command_line');
  const commandLine = await page.evaluate(element => element.innerText, tableCell);
  console.log(commandLine);
Related