Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

280
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda