我正在使用Puppeteer来测量页面及其功能的性能(目前仍处于初始阶段,因为我刚开始)。 以下是我正在使用的示例:
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();
})();
如何在表单提交后访问新加载的页面?我是指用户已经登录,我们如何获取那个新加载页面的控制权呢?