I'm new to JavaScript and Puppeteer.
I tried the login code below, but it failed.
In comparison, I added page2
and succeeded.
How can I solve it?
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();
See Question&Answers more detail:os