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
13
votes
1 answer

Puppeteer npm how to set up fonts from local file

I would like to load fonts from local files while rendering PDF using the puppeteer node module. It worked for me to use web fonts but this does not satisfy requirements. My environment: Node: v10.18.1, Puppeteer: "puppeteer": "^2.0.0", Chromium:…
Hadzo
  • 178
  • 1
  • 3
  • 10
13
votes
2 answers

Configure Puppeteer executablePath chrome in your local Windows

Puppeteer version : 1.11.0 Platform / OS version: Windows 10 pro Node.js version: 12.6.6 When I did a local development test in windows, happen was problem in executablePath. "Failed to launch chrome! spawn /usr/bin/chromium-browser ENOENT" I…
Nellonidas
  • 143
  • 1
  • 1
  • 7
13
votes
1 answer

Headless browser image quality - Headless chrome, phantom js, slimmer js

I'm looking for more information on what takes place under the hood in headless browsers. I've been working with different headless browsers in the past such as slimmerJS, Phantom.js and Headless Chrome, with the purpose of taking screenshots in…
13
votes
2 answers

Puppeteer - get parent element

I'm trying to click on one value (odds) based on the name of the other element but those two need to be inside a specific parent element which I get by the text inside it. The snippet below can be found multiple times on the same page with the same…
SasaFajkovic
  • 395
  • 1
  • 4
  • 16
13
votes
1 answer

puppeteer: Access JSON response of a specific request as in the network tab of DevTools

I'd like to directly get the response of the last HTTP request shown in the screenshot. The current puppeteer code is shown below. Could anybody show me how to modify it so that it will get the JSON response directly from the browser? Thanks. const…
user1424739
  • 11,937
  • 17
  • 63
  • 152
13
votes
2 answers

Using Jest with Puppeteer : Evaluation failed: ReferenceError: cov_4kq3tptqc is not defined

I'm trying to get description of a page with Puppeteer, I have a high order function that provides the page object to this function : export const checkDescription = async page => { const metaDescription = await page.$eval( …
Elena
  • 569
  • 3
  • 7
  • 19
13
votes
3 answers

How to use imported function inside page.evaluate in Puppeteer with Jest?

I have a TypeScript project that uses Jest for unit tests and have just added Puppeteer to the mix with the intention to run some tests on the client. It works fine, unless I try use imported functions inside page.evaluate. For example, I have the…
Vitaly
  • 4,358
  • 7
  • 47
  • 59
13
votes
4 answers

Possible to Get Puppeteer Audio Feed and/or Input Audio Directly to Puppeteer?

I want to input WAV or MP3 into puppeteer as a microphone, however while in headless the application is muted, so I was wondering if there was a way to get input directly into the browser. I am also wondering if it's possible to get a feed of audio…
david elepen
  • 131
  • 1
  • 3
13
votes
1 answer

How to run Jest-Puppeteer test in multiple files

I am using jest-puppeteer to run my webtests. If I am running my tests all defined in one file, everything works perfectly. describe('user', () => { jest.setTimeout(12000); beforeEach(async () => { await page.setViewport({width:…
Stefan
  • 1,590
  • 3
  • 18
  • 33
13
votes
5 answers

Puppeteer - Removing elements by class

I try to remove elements by classname but it doesn't work. This is the code i used: await page.screenshot({path: 'pic.png'}); //for testing purposes let div_selector_to_remove= ".xj7.Kwh5n"; var thingToRemove =…
user1584421
  • 3,499
  • 11
  • 46
  • 86
13
votes
3 answers

Puppeteer get 3rd-party cookies

How can I get 3rd-party cookies from a website using Puppeteer? For first party, I know I can use: await page.cookies()
Piotr Wu
  • 1,362
  • 3
  • 14
  • 31
13
votes
2 answers

How to get all links from the DOM?

According to https://github.com/GoogleChrome/puppeteer/issues/628, I should be able to get all links from < a href="xyz" > with this single line: const hrefs = await page.$$eval('a', a => a.href); But when I try a simple: console.log(hrefs) I only…
Vega
  • 2,661
  • 5
  • 24
  • 49
13
votes
4 answers

Unable to use proxy with puppeteer. Error: ERR_NO_SUPPORTED_PROXIES gets thrown

How to set up a proxy with puppeteer? I tried the following: (async () => { const browser = await puppeteer.launch({ headless: false, args: [ '--proxy-server=http://username:password@zproxy.luminati.io:22225' …
Jatt
  • 665
  • 2
  • 8
  • 20
13
votes
2 answers

How to scrape JSON from puppeteer?

I login to a site and it gives a browser cookie. I go to a URL and it is a json response. How do I scrape the page after entering await page.goto('blahblahblah.json'); ?
Amy Coin
  • 141
  • 1
  • 1
  • 4
13
votes
2 answers

Missing request headers in puppeteer

I want to read the request cookie during a test written with the puppeteer. But I noticed that most of the requests I inspect have only referrer and user-agent headers. If I look at the same requests in Chrome dev tools, they have a lot more…
Bardt
  • 695
  • 1
  • 8
  • 17