Reputation: 4198
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("[email protected]", {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?
Upvotes: 3
Views: 2498
Reputation: 4198
I've got it working by waiting for the page to load first. Then I was able to click the correct element.
So I've added the following line:
await page.waitForNavigation();
before this one:
await page.click(".show-filters");
I must say that the documentation is rather scarce for the tool :(
Upvotes: 7