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
27
votes
4 answers

Injecting CSS into site with Puppeteer

The site I'm running automated tests on with Puppeteer displays info popups if actions were successful or when something failed. Unfortunately, these popups sometimes cover up buttons my script has to click on. It would be great if I could inject…
27
votes
3 answers

Puppeteer Getting List of Elements with Same Selector

Background: Using NodeJS/CucumberJS/Puppeteer to build end-to-end regression test for an emberJS solution. Problem: Selecting (page.click) and getting textContent of one of the elements when there are several dynamic elements with the same selector?…
27
votes
4 answers

Running headless Chrome / Puppeteer with --no-sandbox

Background I built an application that uses Puppeteer on my localhost. Now that I am trying to deploy it into a debian environment the script that runs Puppeteer is timing out. After researching it I realized it is a common problem. Most debian…
wuno
  • 9,547
  • 19
  • 96
  • 180
27
votes
2 answers

Node puppeteer take screenshot full page SPA

I have a single page application with scrolling. I am trying to take a screenshot of the whole page, but it only gives me the visible part. How can I make it shoot the whole page? const browser = await puppeteer.launch(options); const page =…
JsFan
  • 393
  • 2
  • 4
  • 13
26
votes
3 answers

Chrome Headless puppeteer too much CPU

I have a scraping algorithm in nodejs with puppeteer which scrapes 5 pages concurrently and when it finishes with one page it pulls the next url from a queue and open it in the same page. The CPU is always at 100%. How to make puppeteer use less…
Pjotr Raskolnikov
  • 1,558
  • 2
  • 15
  • 27
26
votes
3 answers

How to specify browser language in Puppeteer

I would like to launch a Google Chrome browser with language Spanish es using Puppeteer. I've tried puppeteer.launch(args:['--lang=es',...],...) but it didn't work. I've tried passing the environment variable LANGUAGE=es mocha puppeteer-test.js but…
26
votes
6 answers

Puppeteer Button Press

According to https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepresskey-options, you can simulate the pressing of a keyboard button with Puppeteer. Here's what I do: // First, click the search button await…
25
votes
2 answers

Puppeteer not rendering color, background color when I try to save PDF on disk

This is my node.js and HTML template code which creates a PDF from an HTML template. It's not putting in the colors. const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch(); const page = await…
Rajan Sohal
  • 413
  • 1
  • 5
  • 9
25
votes
5 answers

How to get all html data after all scripts and page loading is done? (puppeteer)

Finally I figured how to use Node.js. Installed all libraries/extensions. So puppeteer is working, but as it was previous with Xmlhttp... it gets only template/body of the page, without needed information. All scripts on the page engage after few…
user10452005
25
votes
13 answers

How can I check that an element is visible with Puppeteer and pure JavaScript?

I wish to check that a DOM element is visible with Puppeteer and pure JavaScript (not jQuery), how can I do this? By visible I mean that the element is displayed through CSS, and not hidden (f.ex. by display: none). For example, I can determine…
aknuds1
  • 65,625
  • 67
  • 195
  • 317
25
votes
8 answers

Debug puppeteer

Is there some way to debug a puppeteer script? One of the buttons just doesn't get clicked for some reason. I've tried all different ways, and actually in another script I get it clicked, but in this one I don't. await page.focus('#outer-container >…
elena
  • 3,740
  • 5
  • 27
  • 38
24
votes
4 answers

puppeteer wait for element disappear or remove from DOM

Is there any way or Puppeteer API we can wait element to disappear or remove from Dom and then continue the execution? E.g I have a loading animation I want to wait until this loading animation remove from Dom.
Mehran Shafqat
  • 422
  • 2
  • 5
  • 16
24
votes
3 answers

How to disable core file dumps in docker container

My PHP container runs puppeteer to generate PDF. By generating a PDF document, it also creates two core dump files inside my container. I am not sure where they actually come from. The host/server is CentOS 7. I've checked following: No application…
Jonathan
  • 538
  • 1
  • 6
  • 18
24
votes
11 answers

Puppeteer doesn't close browser

I'm running puppeteer on express/node/ubuntu as follow: var puppeteer = require('puppeteer'); var express = require('express'); var router = express.Router(); /* GET home page. */ router.get('/', function(req, res, next) { (async () => { …
Elia Weiss
  • 8,324
  • 13
  • 70
  • 110
24
votes
3 answers

Puppeteer Launch Incognito

I am connected to a browser using a ws endpoint (puppeteer.connect({ browserWSEndpoint: '' })). When I launch the browser that I ultimately connect to, is there a way to launch this in incognito? I know I can do something like this: const incognito…