BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

Google's Puppeteer Joins Crowd of Headless Chrome Tools

| by David Iffland Follow 3 Followers on Aug 18, 2017. Estimated reading time: 1 minute |

The Chrome DevTools team has released Puppeteer, a Node API custom-built to control headless Chrome. The tool joins a growing list of third-party tools with similar functionality, forcing them to innovate and grow.

Unlike Selenium, which can target multiple browsers, Puppeteer has a single purpose; it can only drive headless Chrome. It's a Node API, so usage should be familiar to developers.

const puppeteer = require('puppeteer');

(async() => {

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({path: 'example.png'});

browser.close();
})();

Code taken from Puppeteer README

The motiviation behind this project was to vastly simplify working with headless Chrome, which first shipped in Chrome version 59. Google Performance Engineer Paul Irish wrote that working with the existing protocol is very difficult:

I can tell you from personal experience that dealing with the raw DevTools Protocol isn't ideal for a developer writing an automation script, so it's clear there's demand for libraries with this higher-level API.

The community has recognized the same deficiency. Since the retirement of PhantomJS, there's been healthy competition for a replacement. Chromeless, Chrominator, and Chromy have all launched since the announcement of headless Chrome. With a first-party tool like Puppeteer, third-party tools will need to innovate and move quickly in order to stay in the game. Likely the market will see some consolidation.

In a post on Medium, an author that goes by the name Ken Soh says that Google team's entry is a positive for developers:

Of course, if Google decides to embrace this community, things can be rapidly improved and Chrome-based approaches can give developers more choices other than the mature incumbents with established ecosystems.

For now, Chromeless has a some advantages such as the ability to run tests remotely on AWS Lambda, but it's likely that Puppeteer will function on Lambda at some point. Puppeteer currently requires version 7.1 of Node and, as of this writing, Lambda only supports version 6.10.3. For some developers, the thought of testing on only a single browser seems anathema, but Soh thinks testing Chrome may be good enough for a lot of developers:

If your tests work on Chrome or headless Chrome, you’ll have the confidence that your web app will work for your users, at least for the majority of your users.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT