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
18
votes
3 answers

How to run function when any test fails - Jest

I want to run a function / task whenever any jest test fails. Instead of wrapping all of my test's with try / catch or add an if check, is there a way I can utilize the afterEach ? If the test fails then I want it to fail, just run a separate…
Tyler Clark
  • 181
  • 1
  • 3
18
votes
4 answers

What is the proper way to capture a HTTP response with Puppeteer?

I am trying to capture the http response status from a user sign-up. My code looks like this: it.only('returns a 400 response if email is taken', async () => { await page.goto(`${process.env.DOMAIN}/sign-up`) await…
HolyMoly
  • 2,020
  • 3
  • 22
  • 35
17
votes
2 answers

Unable to install Chromium inisde a docker container on M1 macbook

I am Running docker on an M1 Macbook Pro , here i am using this docker script FROM node:current-buster # Create and set user RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb RUN apt-get update && apt install -y…
Srinjoy Choudhury
  • 622
  • 1
  • 4
  • 19
17
votes
5 answers

how do you install and run puppeteer for firefox

Hi I am doing some web automation. I am trying to open a url and I am getting a data URL error in chrome console so I am moving to firefox console to get around the no data urls opening in the chrome console issue. The problem is "npm install…
Roboman Robo
  • 599
  • 2
  • 5
  • 16
17
votes
8 answers

How to maximize browser window using puppeteer?

I am trying to maximize the browser window using puppeteer. I tried below code but the browser is not maximized to full mode. I also did not find any function available in puppeteer library to maximize the window. (async () => { const browser =…
Nikkie08
  • 473
  • 2
  • 5
  • 12
17
votes
3 answers

Connecting Browsers in Puppeteer

Is it possible to connect a browser to puppeteer without instantiating it in puppeteer? For example, running an instance of chromium like a regular user and then connecting that to an instance of puppeteer in code?
Jak
  • 181
  • 1
  • 2
  • 6
17
votes
6 answers

How do I get the ElementHandle's class name when using Puppeteer?

I'm trying to get an ElementHandle's class name using Puppeteer... is it possible? Am I using the wrong approach? In this jsBin is part of my code, so you can understand what I am trying to achieve. CriticalCssPlugin.prototype.load = function( page,…
Gabriel Bueno
  • 480
  • 1
  • 4
  • 17
16
votes
2 answers

puppeteer@5.5.0 install: `node install.js` on M1

I've been trying to work on a code I wrote a couple of months back ran into the following error, > puppeteer@5.5.0 install /Users/xyz/Documents/xyz.github.io/node_modules/puppeteer > node install.js The chromium binary is not available for arm64:…
BPDESILVA
  • 2,040
  • 5
  • 15
  • 35
16
votes
3 answers

How to speed up puppeteer?

A web page has a button and puppeteer must click that button as soon as possible button becomes visible. This button is not always visible and it is becoming visible for everyone at the same time. So i have to refresh constantly to find that button…
Tolgay Toklar
  • 4,151
  • 8
  • 43
  • 73
16
votes
3 answers

puppeteer: Get base64 encoded image without separate download

On a page that does not support downloading images or opening them in new tab, I can use the Chrome Developer (Tools->Network) to right click the image and do "copy image as URI". Is it possible to do the same with puppeteer? I tried to use few…
im-i0dum
  • 474
  • 1
  • 5
  • 13
16
votes
6 answers

How to detect version of chrome used with puppeteer?

I read that puppeteer uses the latest version of chrome with it, where can I find which version it is using? I don't want to access navigator object on the window to get it. Basically nothing runtime. Just want to know if puppeteer as a package…
16
votes
4 answers

Puppeteer: get localStorage from a website

I need to take with Puppeteer all the data that a website saves: cookies and localStorage (for example after Login). I have read all Puppeteer documentation but I can not find anything about localStorage. I can get cookies but I don't know to get…
kurtko
  • 1,978
  • 4
  • 30
  • 47
16
votes
1 answer

Headless browser detection

Do you know any webapps/online tests/online firewalls that are trying to detect if user is using selenium/puppeteer/phantomJS or any other headless browser? I've created my puppeteer online crawler. I've changed many different stuff like…
BT101
  • 3,666
  • 10
  • 41
  • 90
16
votes
3 answers

How to point Puppeteer to local images/fonts?

I want to generate images from the HTML string using Puppeteer. For now I have something like this: const html = _.template(`

Hello {{ test }}!

alt text
bdrtsky
  • 163
  • 1
  • 1
  • 4
16
votes
3 answers

Puppeteer Error: Protocol error (Page.captureScreenshot): Target closed

I have this error running puppeteer@1.12.2 on node:8-slim container. The full error: Error: Protocol error (Page.captureScreenshot): Target closed. at Promise (/app/node_modules/puppeteer/lib/Connection.js:183:56) at new Promise…
Alex Blex
  • 34,704
  • 7
  • 48
  • 75