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

The code below opens up puppeteer with a chrome window and devtools.Devtools opens inside the browser.

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,
});

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,
});
Share Improve this question edited Apr 28, 2020 at 8:40 tomeraz asked Apr 28, 2020 at 7:31 tomeraztomeraz 3234 silver badges16 bronze badges 3
  • You can just detach it manually. – D. Pardal Commented Apr 28, 2020 at 7:34
  • How do I detach it automatically? – tomeraz Commented Apr 28, 2020 at 7:37
  • 2 See this answer, it should work with currentDockState: '"undocked"' inside preferences object. – woxxom Commented Apr 28, 2020 at 7:41
Add a ment  | 

1 Answer 1

Reset to default 6

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
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744131321a4559856.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信