Browser-Automation Library Puppeteer now supports Firefox

0

Mathias BynensGoogle developer working on ChromeDevTools and v8, released Puppeteer 3.0. Puppeteer now supports Firefox in addition to the Chrome browser. The new version also upgraded support to the latest Chrome 81 and removed support for Node 8.

Puppeteer is a Node.js browser test automation library that provides a high-level API for controlling headless Chrome or Chromium via the DevTools protocol. Thus, new versions of Puppeteer are often linked to new versions of the Chrome browser and the deprecation of older versions of Node.js. This is also the case in this version. While Puppeteer 2.0 supported Chrome 79 and deprecated Node 6, Puppeteer 3.0 supports the latest Chrome browser (Chrome 81) and no longer supports Node 8.

However, Puppeteer 3.0 also supports Firefox, a move that is set to increase its use for cross-browser testing purposes. Google announced in passing a first effort (code name puppeteer-firefox) to support Mozilla’s browser at Google I/O ’19 in the Modern Web Testing and Automation with Puppeteer (Google I/O ’19) conference by Andrei Lushnikov and Joel Einbinder. Both developers have since migrated to Microsoft working on Playwright, a Node.js library for simultaneous cross-browser automation that supports all major browser engines (Chromium, WebKit and Firefox) in a single API. Playwright is approaching the release of its first major version with 99% of tests passing (in v0.13).

With Firefox support transitioning to the puppeteer package, the puppeteer-firefox package has been deprecated. Puppeteer can now grab a Firefox Nightly binary. Bynens points to an example of automating Firefox with Puppeteer, the snippet of which is as follows:

To have Puppeteer fetch a Firefox binary for you, first run:
> PUPPETEER_PRODUCT=firefox npm install

To get additional logging about which browser binary is executed, run this example as:
> DEBUG=puppeteer:launcher NODE_PATH=../ node examples/cross-browser.js

- You can set a custom binary with the `executablePath` launcher option.

Bynens also mentions improving the reliability of file uploads, moving to Mocha from the old custom tester framework, and migrating source code to TypeScript. Of the latter, Bynens comments:

While this does not affect how developers can use Puppeteer, it does improve the quality of Puppeteer type definitions that can be used by modern editors.

Developers reacted enthusiastically on Twitter. A developer demand :

Impressive! Also is there a way to install firefox if puppeteer is a dependency of another package published on npm, such as npm install foo automatically installs Puppeteer + Matching Firefox?

Bynens replied that the requested functionality would be implemented once Firefox support is no longer experimental.

More comprehensive coverage of the testing ecosystem is available in InfoQ’s JavaScript and Web Development Trends report. Puppeteer is open source software available under the Apache 2.0 license. Contributions are welcome and must follow the Puppeteer Contribution Guidelines.

Share.

Comments are closed.