Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

281
Views
Puppeteer - Handling multiple Window (same context)

There is very little information available and I've tried multiple things but there isn't a way to know apparently from Puppeteer if the Window is different, for example if I move manually a "tab" (not in headless) outside, this creates a new Window, there is apparently no way to be aware of it or have a concept of Windows in Puppeteer, can someone shed the light on this?

I don't wish to open more Chromium instances as I want to stick with the same profile (without copy), I want to deal with multiple Window (not tabs).

Selenium has a clear way of handling that by using getWindowHandle

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Currently, Puppeteer does not offer an API to do that. The underlying Chrome DevTools Protocol (CDP) might offer what you need. See Target.createTarget's newWindow parameter https://chromedevtools.github.io/devtools-protocol/tot/Target/#method-createTarget. It should be possible to get access to CDP and create a new window as following:

// pseudo-code, not tested if it works.
const client = await browser.target().createCDPSession();
const {targetId} = await client.send('Target.createTarget', { url: ..., newWindow: true });
const newTarget = await browser.waitForTarget(target => target.id === targetId);

It seems newWindow only has an effect in headful mode.

about 4 years ago · Juan Pablo Isaza Report

0

You can try puppeteer-cluster.

This is what the example looks like:

const { Cluster } = require('puppeteer-cluster');

(async () => {
  const cluster = await Cluster.launch({
    concurrency: Cluster.CONCURRENCY_CONTEXT,
    maxConcurrency: 2,
  });

  await cluster.task(async ({ page, data: url }) => {
    await page.goto(url);
    const screen = await page.screenshot();
    // Store screenshot, do something else
  });

  cluster.queue('http://www.google.com/');
  cluster.queue('http://www.wikipedia.org/');
  // many more pages

  await cluster.idle();
  await cluster.close();
})();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!