最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin3浏览0评论

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论