BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Google's Puppeteer Joins Crowd of Headless Chrome Tools

Google's Puppeteer Joins Crowd of Headless Chrome Tools

This item in japanese

Bookmarks

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
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.

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

Community comments

  • Bad Closing Advice

    by Chris Alexander,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Chrome market use is aggregated at ~60% (gs.statcounter.com/browser-market-share). Note the word aggregated as Android/Chrome has multiple versions and OS support. Furthermore, this implies the ~40% UX is NOT worth optimizing? Such talk imbues the air with monopolistic elitism. Create a browser/OS compatibility matrix for your application and strive for a 100% quality UX. Question what you read...

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

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

BT