title: how to handle new page on button click in pupeteer?
body: <p>i am using puppeteer in a project to test a web page , in the page i have several buttons that open a new tab in the browser , how can i handle that using puppeteer? </p>
  
  <pre><code>const puppeteer = require('puppeteer');
  
  (async() =&gt; {
      const browser = await puppeteer.launch({ defaultViewport: null });
  
      const page = await browser.newPage();
  
      // go to the URL
      await page.goto('https://example.com/', {waitUntil: 'networkidle'});
  
      await page.click('.btnId'); //opens new tab with Page 2
  
      // handle Page 2
      // process Page 2
      // close Page 2
  
      // go back to Page 1
  
      browser.close();
  
  })();
  
  </code></pre>
  
  <p>how can i handle the page 2 ?</p>