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
12
votes
6 answers

puppeteer header and footertemplate doesnt work

This is my code for creating the pdf. Everything works great except the footer and header doesn't work. They are there (i think) but not visible. I have tried with displayHeaderFooter: true but all that makes is a date stamp in the header and some…
Daniel Gustafsson
  • 1,725
  • 7
  • 37
  • 78
12
votes
2 answers

waitForNavigation hanging, even though page was loaded

I'm trying to automatically login to a website using puppeteer, with the following script: const puppeteer = require('puppeteer'); async function logIn(userName, password) { const browser = await puppeteer.launch(); const page = await…
bsam
  • 880
  • 1
  • 8
  • 18
12
votes
1 answer

Websocket communication with multiple Chrome Docker containers

I have a Chrome container (deployed using this Dockerfile) that renders pages on request from an App container. The basic flow is: App sends an http request to Chrome and in response receives a websocket url to use (e.g.…
drmrbrewer
  • 11,491
  • 21
  • 85
  • 181
12
votes
3 answers

node js puppeteer metadata

I am new to Puppeteer, and I am trying to extract meta data from a Web site using Node.JS and Puppeteer. I just can't seem to get the syntax right. The code below works perfectly extracting the Title tag, using two different methods, as well as text…
Lauren Kay
  • 121
  • 1
  • 3
12
votes
3 answers

Puppeteer Generate PDF from multiple HTML strings

I am using Puppeteer to generate PDF files from HTML strings. Reading the documentation, I found two ways of generating the PDF files: First, passing an url and call the goto method as follows: page.goto('https://example.com'); page.pdf({format:…
Juan Rivillas
  • 897
  • 2
  • 9
  • 23
12
votes
2 answers

How to pass userDataDir profile folder to Puppeteer

I want to pass a custom profile to Puppeteer. To start I've tried to pass my real Google Chrome profile: const browser = await puppeteer.launch({ userDataDir: '/Users/[USERNAME]/Library/Application Support/Google/Chrome/Default', headless:…
12
votes
4 answers

Getting DOM node text with Puppeteer and headless Chrome

I'm trying to use headless Chrome and Puppeteer to run our Javascript tests, but I can't extract the results from the page. Based on this answer, it looks like I should use page.evaluate(). That section even has an example that looks like what I…
Don Kirkby
  • 53,582
  • 27
  • 205
  • 286
11
votes
4 answers

M1 chip, Install Puppeteer in Docker NodeJs, The chromium binary is not available for arm64

I got an error while building backend docker, specifically installing Puppeteer. I'm using M1 MacBook, and I found a solution on the local machine(https://github.com/puppeteer/puppeteer/issues/6622), but this didn't work on the docker. Has anyone…
Dean
  • 121
  • 1
  • 4
11
votes
3 answers

Can we explicitly catch Puppeteer (Chrome/Chromium) Error net::ERR_ABORTED?

Can we explicitly and specifically catch Puppeteer (Chrome/Chromium) error net::ERR_ABORTED? Or is string matching the only option currently? page.goto(oneClickAuthPage).catch(e => { if (e.message.includes('net::ERR_ABORTED')) {} }) /* …
anthumchris
  • 8,245
  • 2
  • 28
  • 53
11
votes
3 answers

Puppeteer: Failed to launch the browser process! spawn

When I try to run node app.js, I get error: the message is Failed to launch the browser process! spawn /Users/iliebogdanbarbulescu/Downloads/firstProject/node_modules/chromium/lib/chromium/chrome-mac/Chromium.app EACCES What I did I checked the…
bibscy
  • 2,598
  • 4
  • 34
  • 82
11
votes
4 answers

How to get puppeteer working in Google Cloud Run/Cloud Build?

I have a docker image containing a puppeteer web scraper. It works perfectly in my local machine when I build and run it. It also build fine in cloud build, deploys to cloud run and starts the http server. However, when I run one of the cron jobs…
11
votes
4 answers

How to use puppeteer-core with electron?

I got this code from another Stackoverflow Question: import electron from "electron"; import puppeteer from "puppeteer-core"; const delay = (ms: number) => new Promise(resolve => { setTimeout(() => { resolve(); }, ms); }); (async…
pouya
  • 3,400
  • 6
  • 38
  • 53
11
votes
5 answers

How to test custom web component with jest?

I would like to test some custom web components and use jest.js as test runner (due to its support for ES6). Chromium supports commands like window.customElements.define('my-custom-element', MyCustomElementClass); to register a custom web…
Stefan
  • 10,010
  • 7
  • 61
  • 117
11
votes
2 answers

'--disable-dev-shm-usage' does not resolve the Chrome crash issue in Docker

Since our e2e test has expanded to over 50+ tests we decided to run tests in parallel to speed it up. Since default gitlab pipeline has limited resources (and dev-shm-size trick did not worked) we decided to use our own AWS runner. For those who…
Yuriy Gerasimovich
  • 424
  • 1
  • 4
  • 15
11
votes
3 answers

How to run Puppeteer code in any web browser?

I'm trying to do some web scraping with Puppeteer and I need to retrieve the value into a Website I'm building. I have tried to load the Puppeteer file in the html file as if it was a JavaScript file but I keep getting an error. However, if I run it…
user10021033