puppeteer newly loaded page after the form submit

Viewed 2135

I am using puppeteer to measure the performance of the pages and their features (this is still in the initial phase, since I am just starting). Here's an example I am using:

const puppeteer = require('puppeteer');
(async () => {

    const browser = await puppeteer.launch({headless: false});
    const page = await browser.newPage();
    await page._client.send('Performance.enable');
    await page.goto('https://xxxx.com');
    await page.focus("#formulario input#username");
    await page.type("test2222@gmail.com", {delay: 200});
    await page.focus("#formulario input#inputPassword3");
    await page.type("pass", {delay: 200});
    const loginForm = await page.$("#formulario");
    await loginForm.evaluate(loginForm => loginForm.submit());
    loginForm._client.send('Performance.getMetrics');
    //BELOW DOESN'T WORK BECAUSE THE PAGE IS GONE
    await page.click("span.show-filters");

    await browser.close();
})();

How to access the newly loaded page after a form is submitted? I mean the user has logged in and how can we get a handle of that newly loaded page?

1 Answers
Related