Questions tagged [puppeteer]

Puppeteer is a Node.js library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome or Chromium.

Puppeteer is a Node.js library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome or Chromium. You can also use Puppeteer with Firefox Nightly (experimental support).


Puppeteer is mostly used for:

  1. Generate screenshots and PDFs of pages.
  2. Crawl an SPA and generate pre-rendered content (i.e. "SSR").
  3. Scrape content from websites.
  4. Automate form submission, UI testing, keyboard input, etc.
  5. Create an up-to-date, automated testing environment. Run your tests directly in the latest version of Chrome using the latest JavaScript and browser features.
  6. Capture a timeline trace of your site to help diagnose performance issues.

Resources:

Books:

7753 questions
490
votes
25 answers

Message "Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout"

I'm using Puppeteer and Jest to run some front end tests. My tests look as follows: describe("Profile Tab Exists and Clickable: /settings/user", () => { test(`Assert that you can click the profile tab`, async () => { await…
Asool
  • 13,031
  • 7
  • 35
  • 49
269
votes
7 answers

How can I pass variable into an evaluate function?

I'm trying to pass a variable into a page.evaluate() function in Puppeteer, but when I use the following very simplified example, the variable evalVar is undefined. I can't find any examples to build on, so I need help passing that variable into the…
Cat Burston
  • 2,833
  • 2
  • 12
  • 10
145
votes
8 answers

puppeteer: wait N seconds before continuing to the next line

In puppeteer I would like to wait a defined time before going to the next line of code. I've tried to put a setTimeout in an evaluate function but it seems to be simply ignored console.log('before waiting'); await page.evaluate(async() => { …
Pipo
  • 5,170
  • 7
  • 33
  • 66
140
votes
10 answers

How do you click on an element with text in Puppeteer?

Is there any method or solution to click on an element with text? I couldn't find one in the API. For example I have the following HTML:
Href text
Div…
Aleksandr Golubovskij
  • 1,493
  • 3
  • 12
  • 9
124
votes
14 answers

Puppeteer wait page load after form submit

I submit a form using the following code and i want Puppeteer to wait page load after form submit. await page.click("button[type=submit]"); //how to wait until the new page loads before taking screenshot? // i don't want this: // await…
redochka
  • 12,345
  • 14
  • 66
  • 79
116
votes
15 answers

Puppeteer wait until page is completely loaded

I am working on creating PDF from web page. The application on which I am working is single page application. I tried many options and suggestion on https://github.com/GoogleChrome/puppeteer/issues/1412 But it is not working const browser =…
108
votes
9 answers

How to fill an input field using Puppeteer?

I'm using Puppeteer for E2E test, and I am now trying to fill an input field with the code below: await page.type('#email', 'test@example.com'); It worked, but I found the email address was typed into the field one character by one character as if…
choasia
  • 10,404
  • 6
  • 40
  • 61
108
votes
9 answers

How to select an option from dropdown select

I can click the selector but my question is how to select one of the options from the dropdown list? await page.click('#telCountryInput > option:nth-child(4)') Click the option using CSS selector does not work. For example, select a country code…
XY L
  • 25,431
  • 14
  • 84
  • 143
100
votes
7 answers

Node.js puppeteer - How to set navigation timeout?

I'm using node.js and puppeteer to get some data. Some of the files I'm opening are quite large ... and then I get an error: Error: our error { TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded at Promise.then…
Philipp M
  • 3,306
  • 5
  • 36
  • 90
100
votes
11 answers

Puppeteer - scroll down until you can't anymore

I am in a situation where new content is created when I scroll down. The new content has a specific class name. How can I keep scrolling down until all the elements have loaded? In other words, I want to reach the stage where if I keep scrolling…
user1584421
  • 3,499
  • 11
  • 46
  • 86
92
votes
8 answers

puppeteer: how to wait until an element is visible?

I would like to know if I can tell puppeteer to wait until an element is displayed. const inputValidate = await page.$('input[value=validate]'); await inputValidate.click() // I want to do something like that waitElemenentVisble('.btnNext…
Pipo
  • 5,170
  • 7
  • 33
  • 66
90
votes
4 answers

How to get all console messages with puppeteer? including errors, CSP violations, failed resources, etc

I am fetching a page with puppeteer that has some errors in the browser console but the puppeteer's console event is not being triggered by all of the console messages. The puppeteer chromium browser shows multiple console messages However,…
Carlos E Silva
  • 1,001
  • 1
  • 7
  • 5
87
votes
7 answers

Opening local HTML file using Puppeteer

Is it possible to open a local HTML file with headless Chrome using Puppeteer (without a web server)? I could only get it to work against a local server. I found setContent() and goto() in the Puppeteer API documentation, but: page.goto: did not…
Anil Namde
  • 6,452
  • 11
  • 63
  • 100
81
votes
30 answers

Error: Failed to launch the browser process puppeteer

checked failed crashForExceptionInNonABIComplianceCodeRange the code below its functon is to create PDF file (async function() { try { const browser = await puppeteer.launch(); const page = await browser.newPage(); …
Abu Dujana Mahalail
  • 1,547
  • 1
  • 8
  • 21
81
votes
4 answers

How to manage log in session through headless chrome?

I want to create a scraper that: opens a headless browser, goes to a url, logs in (there is steam oauth), fills some inputs, and clicks 2 buttons. My problem is that every new instance of headless browser clears my login session, and then I need…
Anton Kurtin
  • 813
  • 1
  • 7
  • 7
1
2 3
99 100