Install a Chrome Extension Using Puppeteer and the Debug Protocol

How can Puppeteer open a new tab in an active Chrome session to load an extension page? This avoids errors like net::ERR_BLOCKED_BY_CLIENT.

const controller = require('puppeteer');

(async function executeTest() {
  const cleanArgs = controller.defaultArgs().filter(arg => arg.toLowerCase() !== '--disable-extensions');
  const launcher = await controller.launch({
    headless: false,
    devtools: true,
    args: cleanArgs.concat(['--remote-debugging-port=9222'])
  });
  const browserInstance = await controller.connect({
    browserWSEndpoint: launcher.wsEndpoint()
  });
  const tab = await browserInstance.newPage();
  await tab.goto('chrome-extension://sample_ext_id/ui.html');
})();

hey, try delaying the navigation call. sometimes chrome needs an extra sec to init the extention. also, double chekc the ext id for typos. works for me when i give a little extra time before accessing the page.

In my work with Puppeteer and Chrome extensions, I discovered that managing the timing of page navigation is essential. Rather than relying on a fixed timeout, I implemented a wait strategy that confirmed the extension was fully loaded. Using page.waitForSelector or a similar approach made it easier to determine if necessary elements were present before navigating to the extension page. This method proved more robust, as it accounted for varying initialization times. Ensuring that the extension is fully active before attempting to interact with it has helped reduce errors in my projects.

I have encountered similar issues when trying to access Chrome extensions via Puppeteer. In my experience, the key is to ensure that the debugging port is properly set up and to wait for the extension loading events to complete. Once, I ran into a situation where the extension page was not fully rendered before navigation, resulting in ERR_BLOCKED_BY_CLIENT errors. I resolved it by implementing a wait on a specific selector that indicated the extension was ready. This approach not only helped ensure the environment was stable but also reduced intermittent test failures.