I am messing with Puppeteer and I am having trouble getting it to take a PDF of a new page.
I can get a PDF of the initial URL just fine, but if I try to get a PDF of a page I open via clicking on a link, it just takes a PDF of the initial page like always.
This is my code:
const puppeteer = require('puppeteer');
async function takePDF(){
const browser = await puppeteer.launch({
slowMo:500, defaultViewport:null
});
const page = await browser.newPage();
startUrl = 'https://www.google.com/';
await page.goto(startUrl);
await page.mouse.click(1030,468, { button: 'left'}); //click I'm Feeling Lucky
await page.pdf({path: 'screenshot.pdf'}); //take pdf of I'm Feeling Lucky Results
browser.close();
}
takePDF();
Do I have to fetch the URL and explicitly tell it it's on a new page now? Thanks.