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

333
Views
Is there a way to open multiple tabs simultaneously on Playwright or Puppeteer to complete the same tasks?

I just started coding, and I was wondering if there was a way to open multiple tabs concurrently with one another. Currently, my code goes something like this:

const puppeteer = require("puppeteer");

const rand_url = "https://www.google.com";

async function initBrowser() {
  const browser = await puppeteer.launch({ headless: false });
  const page = await browser.newPage();
  await page.goto(rand_url);
  await page.setViewport({
    width: 1200,
    height: 800,
  });

  return page;
}

async function login(page) {
  await page.goto("https://www.google.com");
  await page.waitFor(100);
  await page.type("input[id ='user_login'", "xxx");
  await page.waitFor(100);
  await page.type("input[id ='user_password'", "xxx");
}

this is not my exact code, replaced with different aliases, but you get the idea. I was wondering if there was anyone out there that knows the code that allows this same exact browser to be opened on multiple instances, replacing the respective login info only. Of course, it would be great to prevent my IP from getting banned too, so if there was a way to apply proxies to each respective "browser"/ instance, that would be perfect.

Lastly, I would like to know whether or not playwright or puppeteer is superior in the way they can handle these multiple instances. I don't even know if this is a possibility, but please enlighten me. I want to learn more.

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

0

There are profiling and proxy options; you could combine them to achieve your goal:

Profile, https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context

import { chromium } from 'playwright'
const userDataDir = /tmp/ + process.argv[2]
const browserContext = await chromium.launchPersistentContext(userDataDir)
// ...

Proxy, https://playwright.dev/docs/api/class-browsertype#browser-type-launch

import { chromium } from 'playwright'
const proxy = { /* secret */ }
const browser = await chromium.launch({
  proxy: { server: 'pre-context' }
})
const browserContext = await browser.newContext({
  proxy: {
    server: `http://${proxy.ip}:${proxy.port}`,
    username: proxy.username,
    password: proxy.password,
  }
})
// ...
about 4 years ago · Juan Pablo Isaza Report

0

You can use multiple browser window as different login/cookies.
For simplicity, you can use the puppeteer-cluster module by Thomas Dondorf.
This module can make your puppeteer launched and queued one by one so that you can use this to automating your login, and even save login cookies for the next launches.
Feel free to go to the Github: https://github.com/thomasdondorf/puppeteer-cluster

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

(async () => {
  const cluster = await Cluster.launch({
    concurrency: Cluster.CONCURRENCY_CONTEXT,
    maxConcurrency: 2, // <= this is the number of
                       // parallel task running simultaneously
  })                   // You can change to the number of CPU
  const cpuNumber = require('os').cpus().length // for example

  await cluster.task(async ({ page, data: [username, password] }) => {
    await page.goto('https://www.example.com')
    await page.waitForTimeout(100)
    await page.type('input[id ="user_login"', username)
    await page.waitForTimeout(100)
    await page.type('input[id ="user_password"', password)
    const screen = await page.screenshot()
    // Store screenshot, Save Cookies, do something else
  });

     cluster.queue(['myFirstUsername', 'PassW0Rd1'])
     cluster.queue(['anotherUsername', 'Secr3tAgent!'])
  // cluster.queue([username, password])
  // username and password array passed into cluster task function 
  // many more pages/account

  await cluster.idle()
  await cluster.close()
})()

For Playwright, sadly still unsupported by the module above,
you can use browser pool (cluster) module to automating the Playwright launcher.

And for proxy usage, I recommend Puppeteer library as the legendary one.

Don't forget to choose my answer as the right one, if this helps you.

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!