Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open puppeteer with chrome window and devtools on a separate window (detached) automatically?

The code below opens up puppeteer with a chrome window and devtools. Devtools opens inside the browser. Is there a way make devtools open in a sepearate window?

const puppeteer = require("puppeteer");
const browser = await puppeteer.launch({
    headless: false,
    devtools: true,
});
like image 514
tomeraz Avatar asked Oct 14 '25 15:10

tomeraz


1 Answers

Depends on wOxxOm's answer, here's a working example, note that puppeteer should import from puppeteer-extra

import puppeteer from 'puppeteer-extra';
import ppUserPrefs from 'puppeteer-extra-plugin-user-preferences';

puppeteer.use(ppUserPrefs({
  userPrefs: {
    devtools: {
      preferences: {
        currentDockState: '"undocked"'
      },
    },
  }
}));

puppeteer.launch({
  headless: false,
  devtools: true
});
like image 168
imckl Avatar answered Oct 17 '25 08:10

imckl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!