In Puppeteer, is it possible to launch a headed browser instance, get the user authenticated, and then continue the session in a headless state?

Viewed 11

This will connect but will still keep the original browser open and navigate inside of it, even when called from the headlessBroswer's headlessPage


  let launchHeadBrowserOptions = { headless: false };
  let launchHeadlessBrowserOptions = { headless: true };

  const browser = await puppeteer.launch(launchHeadBrowserOptions);
  const page = await browser.newPage();

  await page.goto(url);

  // authentication ==> now want to be headless

  let headlessBrowser = await puppeteer.launch(launchHeadlessBrowserOptions);
  headlessBrowser = await puppeteer.connect({
    browserWSEndpoint: browser.wsEndpoint(),
  });

  const headlessPage = await headlessBrowser.newPage();
  await headlessPage.goto(url);

0 Answers
Related