我是JavaScript和Puppeteer的新手。我尝试了下面的登录代码,但失败了。相比之下,我添加了page2
并成功了。我该怎么解决呢?
const CREDS = require('./creds');
async function main() {
const puppeteer = require('puppeteer');
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.setViewport({width: 1200, height: 720})
await page.goto('https://www.daum.net');
await page.waitForNavigation();
await page.type('#id', CREDS.username);
await page.type('#loginPw', CREDS.password);
await page.click('#loginSubmit');
const page2 = await browser.newPage();
await page2.setViewport({width: 1200, height: 720})
await page2.goto('https://google.com');
await page2.type('#lst-ib', 'Headless Chrome');
}
main();
{ waitUntil: 'networkidle0' }
?我只看到page.waitForNavigation()
,它完美地工作。 - ThangLe