Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

279
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda