scythargon
scythargon

Reputation: 3491

Puppeteer: How to open an actual new window instead of tab?

Every time you do await browser.newPage(); - Puppeteer opens a new tab in the same browser window. But I need an actual new window with bookmarks bar and stuff, so popups open via JS won't work.

Upvotes: 2

Views: 1868

Answers (1)

theDavidBarton
theDavidBarton

Reputation: 8851

To open new windows (browser instances) you will need to call await puppeteer.launch() more times. Note that it will use more resources than if you'd open new tabs.

You might find useful the concept of BrowserContext in Puppeteer, where you can make use of browser.createIncognitoBrowserContext().

Example from the docs:

// Create a new incognito browser context
const context = await browser.createIncognitoBrowserContext();
// Create a new page inside context.
const page = await context.newPage();
// ... do stuff with page ...
await page.goto('https://example.com');
// Dispose context once it's no longer needed.
await context.close();

Upvotes: 3

Related Questions