Google’s puppeteer joins the crowd of headless Chrome tools

0

The Chrome DevTools team has released Puppeteer, a custom-built Node API for controlling Chrome headless. 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 goal; it can only drive chrome headless. It’s a Node API, so it 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 extracted from the puppeteer’s README file

The motivation behind this project was to greatly 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 is not ideal for a developer writing an automation script, so clearly there is a demand for libraries with this higher level API.

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

In a post on Medium, an author who goes by the name of Ken Soh says the Google team’s input is positive for developers:

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

For now, Chromeless has some advantages such as the ability to run tests remotely on AWS Lambda, but it’s likely that Puppeteer will run on Lambda at some point. Puppeteer currently requires Node version 7.1, and as of today Lambda only supports version 6.10.3. For some developers, the idea of ​​single-browser testing seems anathema, but Soh thinks testing Chrome may be enough for many developers:

If your tests work on Chrome or Headless Chrome, you’ll be confident that your web application will work for your users, at least for the majority of your users.

Share.

Comments are closed.