From 1e5d9fd8c00705cf00f4472b379edffa6e121edc Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 15 Aug 2017 17:33:03 -0700 Subject: [PATCH] Proofreading documentation (#274) This patch fixes documentation in a few places. --- README.md | 43 ++----------------------------------------- docs/api.md | 6 +++--- package.json | 2 +- 3 files changed, 6 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index cacc48f0..a1d7af3c 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ yarn add puppeteer # or "npm i puppeteer" ``` -> **Note**: When you install Puppeteer, it downloads a recent version of Chromium (~71Mb Mac, ~90Mb Linux, ~110Mb Win) that is guaranteed to work with the API. However, you can [tell Puppeteer to use any Chromium executable](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#new-browseroptions) installed on the machine. +> **Note**: When you install Puppeteer, it downloads a recent version of Chromium (~71Mb Mac, ~90Mb Linux, ~110Mb Win) that is guaranteed to work with the API. ### Usage @@ -52,22 +52,6 @@ browser.close(); })(); ``` -or, without `async`/`await`: - -```js -const puppeteer = require('puppeteer'); - -puppeteer.launch() - .then(browser => browser.newPage()) - .then(page => { - page.goto('https://example.com').then(response => { - page.screenshot({path: 'example.png'}).then(buffer => { - browser.close(); - }); - }); - }); -``` - Puppeteer sets an initial page size to 800px x 600px, which defines the screenshot size. The page size can be customized with [`Page.setViewport()`](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagesetviewportviewport). **Example** - create a PDF. @@ -124,23 +108,12 @@ Check out [contributing guide](https://github.com/GoogleChrome/puppeteer/blob/ma # FAQ -#### Q: What is Puppeteer? - -Puppeteer is a light-weight Node module to control headless Chrome using the latest version of the [DevTools Protocol](https://chromedevtools.github.io/devtools-protocol/). - #### Q: Which Chromium version does Puppeteer use? Look for `chromium_revision` in [package.json](https://github.com/GoogleChrome/puppeteer/blob/master/package.json). Puppeteer bundles Chromium to insure that the latest features it uses are guaranteed to be available. As the DevTools protocol and browser improve over time, Puppeteer will be updated to depend on newer versions of Chromium. -#### Q: Does Puppeteer work with headless Chromium? - -Yes. Puppeteer runs Chromium in [headless mode](https://developers.google.com/web/updates/2017/04/headless-chrome) by default. - -#### Q: Why do most of the API methods return promises? - -Since Puppeteer's code is run by Node, it exists out-of-process to the controlled Chromium instance. This requires most of the API calls to be asynchronous to allow the necessary roundtrips to the browser. #### Q: What is the difference between Puppeteer, Selenium / WebDriver, and PhantomJS? @@ -148,20 +121,8 @@ Selenium / WebDriver is a well-established cross-browser API that is useful for Puppeteer works only with Chrome. However, many teams only run unit tests with a single browser (e.g. Phantom). In non-testing use cases, Puppeteer provides a powerful but simple API because it's only targeting one browser that enables you to rapidly develop automation scripts. -PhantomJS uses an older version of WebKit as it's browser rendering engine. Puppeteer uses the latest -versions of Chromium, which use the Blink rendering engine. +Puppeteer uses the latest versions of Chromium. -#### Q: How is this different than Chromeless? - -[Chromeless](https://github.com/graphcool/chromeless) and Puppeteer are similar projects. -Both are Node libraries that provide a high-level JS APIs to control headless Chrome. - -Chromeless is intended to work well with AWS Lambda to deploy parallel testing in a serverless setup. -Under the hood, it uses [chrome-remote-interface](https://www.npmjs.com/package/chrome-remote-interface) to interface with the DevTools Protocol. In the future, it could use Puppeteer's API. - -Puppeteer is smaller in size (ignoring the bundled version of Chrome) and does not use -dependencies to interface with Chrome. It's API is inspired by other popular automated testing -libraries like PhantomJS and [NightmareJS](http://www.nightmarejs.org/). #### Q: Who maintains Puppeteer? diff --git a/docs/api.md b/docs/api.md index f75a9100..b43f788a 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,4 +1,4 @@ -# Puppeteer API v0.1.0 +# Puppeteer API v0.9.0 ##### Table of Contents @@ -316,7 +316,7 @@ const crypto = require('crypto'); puppeteer.launch().then(async browser => { let page = await browser.newPage(); page.on('console', console.log); - await page.setInPageCallback('md5', text => crypto.createHash('md5').update(text).digest('hex')); + await page.addBinding('md5', text => crypto.createHash('md5').update(text).digest('hex')); await page.evaluate(async () => { // use window.md5 to compute hashes let myString = 'PUPPETEER'; @@ -336,7 +336,7 @@ const fs = require('fs'); puppeteer.launch().then(async browser => { let page = await browser.newPage(); page.on('console', console.log); - await page.setInPageCallback('readfile', async filePath => { + await page.addBinding('readfile', async filePath => { return new Promise((resolve, reject) => { fs.readFile(filePath, 'utf8', (err, text) => { if (err) diff --git a/package.json b/package.json index 1e63146f..1a08520a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "puppeteer", - "version": "0.1.0", + "version": "0.9.0", "description": "", "main": "index.js", "repository": "github:GoogleChrome/puppeteer",