Rendering WebGL image in headless chrome without a GPU

There’s an open bug which affects systems without X11 libraries: crbug.com/swiftshader/79. It prevents Chrome OS from running with SwiftShader, but the same issue would also happen on a headless Linux system which has no X11 support. Fortunately it should be feasible to install X11 and get things running. I’m not 100% sure which packages provide … Read more

Puppeteer is not able to install: “ERROR: Failed to set up Chromium r782078! Set “PUPPETEER_SKIP_DOWNLOAD” env variable to skip download”

Note: This is for UbuntuĀ 18.04 (Bionic Beaver). However, it should be a similar process for Windows though. Set the environment variable (as the error suggests): Mac export PUPPETEER_SKIP_DOWNLOAD=’true’ Windows SET PUPPETEER_SKIP_DOWNLOAD=’true’ and then… npm i puppeteer

How to use proxy in puppeteer and headless Chrome?

You can find an example about proxy at here ‘use strict’; const puppeteer = require(‘puppeteer’); (async() => { const browser = await puppeteer.launch({ // Launch chromium using a proxy server on port 9876. // More on proxying: // https://www.chromium.org/developers/design-documents/network-settings args: [ ‘–proxy-server=127.0.0.1:9876’ ] }); const page = await browser.newPage(); await page.goto(‘https://google.com’); await browser.close(); })();

page.evaluate Vs. Puppeteer $ methods

The main difference between those lines of code is the interaction between the Node.js and the browser environment. The first code snippet will do the following: Run document.querySelector in the browser and return the element handle (to the Node.js environment) Run getProperty on the handle and return the result (to the Node.js environment) Click an … Read more

Set localstorage items before page loads in puppeteer?

You have to register localStorage item like this: await page.evaluate(() => { localStorage.setItem(‘token’, ‘example-token’); }); You should do it after page page.goto – browser must have an url to register local storage item on it. After this, enter the same page once again, this time token should be here before the page is loaded. Here … Read more

Puppeteer: How to listen to a specific response?

One option is to do the following: page.on(‘response’, response => { if (response.url().endsWith(“your/match”)) console.log(“response code: “, response.status()); // do something here }); This still catches all requests, but allows you to filter and act on the event emitter. https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#event-response

How to login in Puppeteer?

page.waitForNavigation(); waits for navigation after a click or any navigation action that triggers from the page. You should probably add the waitForNavigation() after the page.click(). await Promise.all([ page.click(‘#loginSubmit’), page.waitForNavigation({ waitUntil: ‘networkidle0’ }), ]); It will wait until both promises resolve. So now your initial code would look like this: const puppeteer = require(‘puppeteer’); async function … Read more