ashish singh
ashish singh

Reputation: 6904

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 lists out its dependency somewhere

Basically, I want to look up what all CSS and javascript support I can assume to be there from other sites like 'can I use' or chrome references.

Upvotes: 16

Views: 38274

Answers (6)

Monte Hurd
Monte Hurd

Reputation: 4437

I had some requirements where it made sense to refine and bundle some of the logic below into two npm packages:

https://www.npmjs.com/package/puppeteer-chromium-version-finder

https://www.npmjs.com/package/chromium-version-deb-finder

Hopefully these will be useful to others.

^ these supersede the rest of my previous comment below


Quick and dirty bash script gets the Chromium version number usually within a patch release or two of what's seen in the Puppeteer docs:

PUPPETEER_VERSION=$(node -p "require('puppeteer-core/package.json').version"); \
CHROME_REVISION=$(node -e "const revisions = require('./node_modules/puppeteer-core/lib/cjs/puppeteer/revisions.js'); console.log(revisions.PUPPETEER_REVISIONS.chromium)"); \
REVISION_URL=$(curl -Ls -o /dev/null -w %{url_effective} http://crrev.com/$CHROME_REVISION); \
CHROME_VERSION=$(curl --silent "$REVISION_URL/chrome/VERSION?format=TEXT" | base64 --decode); \
CHROME_VERSION="${CHROME_VERSION//$'\n'/\.}"; \
CHROME_VERSION="${CHROME_VERSION//[!\.0-9]/}"; \
echo "Chromium $CHROME_VERSION - Puppeteer v$PUPPETEER_VERSION";

Needs to be run in same directory which contains node_modules - and you need puppeteer-core to already be present in node_modules.

I'm playing with this for a setup which uses puppeteer-core, so doesn't have the Chromium install capabilities of puppeteer proper.

The CHROME_REVISION number, for example, 961656, can also be used to find binaries for given architectures:

Mac_Arm:

https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac_Arm/961656/

Linux_x64:

https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/961656/

Edit: here's a function:

get_puppeteer_core_chromium_version() {
  local puppeteer_version=$(node -p "require('puppeteer-core/package.json').version")
  local chrome_revision=$(node -e "const revisions = require('./node_modules/puppeteer-core/lib/cjs/puppeteer/revisions.js'); console.log(revisions.PUPPETEER_REVISIONS.chromium)")
  local revision_url=$(curl -Ls -o /dev/null -w %{url_effective} http://crrev.com/"$chrome_revision")
  local chrome_version=$(curl --silent "$revision_url/chrome/VERSION?format=TEXT" | base64 --decode)
  chrome_version="${chrome_version//$'\n'/\.}"
  chrome_version="${chrome_version//[!\.0-9]/}"
  echo "$chrome_version"
}

chromium_version=$(get_puppeteer_core_chromium_version)
echo "Chromium version: $chromium_version"

Upvotes: 0

Daniel
Daniel

Reputation: 1472

You can run this in node if you are in the root of your project (the same level as your node_modules dir)

(async()=>{const x = require("puppeteer"); console.log(await(await(await x.launch()).newPage()).browser().version())})()

My Result: > HeadlessChrome/91.0.4469.0

I find this method easier since you can run it on your server without doing file manipulations.

(This answers assumes you can't use top level async await, but even if you can this will work)

Upvotes: 4

Dmitry Davydov
Dmitry Davydov

Reputation: 1082

Here is another way to check out what is Chromium version Puppeteer uses:

  1. Open the revisions.js file inside node_modules/puppeteer. You can use the shell command:
    find ./node_modules -regex ".*puppeteer.*revisions.js" | head -n 1 | xargs cat
  2. Copy Chromium revision number '901912'.
  3. Go to https://omahaproxy.appspot.com/.
  4. Insert the revision number in the format r901912 to the "Find releases" and submit enter image description here
  5. After that you'll see the version of the Chromium that is bundled with the Puppeteerenter image description here

Upvotes: 1

Esakkiappan .E
Esakkiappan .E

Reputation: 565

Another way to get puppeteer version by command and check the chrome version supported for the installed puppeteer in https://www.npmjs.com/package/puppeteer

cat <puppeteer_dir>/package.json | grep "\"version\":"

For me, puppeteer_dir= /home/packages/node_modules/puppeteer

Result is "version": "5.3.1" and respected supported chrome version is chrome-85

Upvotes: -2

opensource-developer
opensource-developer

Reputation: 3058

In the latest version of node, the above code returns a promise object.

You would need to do something like this to get the browser version

await page.browser().version().then(function(version) {
console.log(version);
});

should print something like this HeadlessChrome/84.0.4143.2

Upvotes: 1

Thomas Dondorf
Thomas Dondorf

Reputation: 25240

Use the browser.version() function to find out during runtime which version is used.

If you have the page object you can use it like this:

const version = await page.browser().version();

To find out which Chromium version is bundled with the puppeteer version without starting, you should check out the release notes, there is always a section about the Chromium version which is used.

Example (taken from release notes from v1.14.0):

Big Changes

  • Chromium 75.0.3738.0 (r641577)

Upvotes: 25

Related Questions