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?
(我在一个项目中使用puppeteer来测试网页,在该页面中,我有几个按钮可以在浏览器中打开一个新选项卡,我如何使用puppeteer来处理呢?)
const puppeteer = require('puppeteer');
(async() => {
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();
})();
how can i handle the page 2 ?
(我该如何处理第2页?)
ask by MirzaPayam translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…