Puppeteer: How to listen to a specific response?

One option is to do the following: page.on(‘response’, response => { if (response.url().endsWith(“your/match”)) console.log(“response code: “, response.status()); // do something here }); This still catches all requests, but allows you to filter and act on the event emitter. https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#event-response

/tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory Vercel

I had the same issue where puppeteer was running okay on my local environment but when i deployed to AWS EC2 i face up the same error shared loading libraries Solution First check the version of nodejs you are running and if its not less than v14.0 or greater than v14.0. Upgrade or downgrade (recommended … Read more

How to login in Puppeteer?

page.waitForNavigation(); waits for navigation after a click or any navigation action that triggers from the page. You should probably add the waitForNavigation() after the page.click(). await Promise.all([ page.click(‘#loginSubmit’), page.waitForNavigation({ waitUntil: ‘networkidle0’ }), ]); It will wait until both promises resolve. So now your initial code would look like this: const puppeteer = require(‘puppeteer’); async function … Read more

Puppeteer – How to fill form that is inside an iframe?

I figured it out myself. Here’s the code. console.log(‘waiting for iframe with form to be ready.’); await page.waitForSelector(‘iframe’); console.log(‘iframe is ready. Loading iframe content’); const elementHandle = await page.$( ‘iframe[src=”https://example.com”]’, ); const frame = await elementHandle.contentFrame(); console.log(‘filling form in iframe’); await frame.type(‘#Name’, ‘Bob’, { delay: 100 });

Puppeteer: How to handle multiple tabs?

A new patch has been committed two days ago and now you can use browser.pages() to access all Pages in current browser. Works fine, tried myself yesterday 🙂 Edit: An example how to get a JSON value of a new page opened as ‘target: _blank’ link. const page = await browser.newPage(); await page.goto(url, {waitUntil: ‘load’}); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)