const puppeteer = require('puppeteer'); // puppeteer
const browser = await puppeteer.launch(); // run browser
const page1 = await browser.newPage(); // open new tab
await page1.goto('https://google.com'); // go to google.com
const page2 = await browser.newPage(); // open new tab
await page2.goto('https://github.com'); // go to github.com
await page2.bringToFront(); // make the tab active
…
await browser.close(); // close browser
Как открыть ссылку в новой вкладке
const puppeteer = require('puppeteer'); // puppeteer
const browser = await puppeteer.launch(); // run browser
const page1 = await browser.newPage(); // open new tab
await page1.goto('https://google.com'); // go to google.com
await page1.waitForSelector('#fsl > a:nth-child(4)'); // wait load object
const link = await page1.$('#fsl > a:nth-child(4)'); // declare object
const newPagePromise = new Promise(x => browser.once('targetcreated', target => x(target.page()))); // declare promise
await link.click({button: 'middle'}); // click middle button, link open in a new tab
const page2 = await newPagePromise; // declare new tab, now you can work with it
await page2.bringToFront(); // make the tab active
…
await browser.close(); // close browser