How to switch between tabs with Puppeteer?
问题 Here is my use case: I have a link which on clicking opens a new tab and loads the content. What I am looking for: Is there a way to switch the reference of the page while new tab opens or create a reference for the new tab? 回答1: Use next function: let clickAndWaitForTarget = async (clickSelector, page, browser) => { const pageTarget = page.target(); //save this to know that this was the opener await page.click(clickSelector); //click on a link const newTarget = await browser.waitForTarget