mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Proofreading documentation (#274)
This patch fixes documentation in a few places.
This commit is contained in:
parent
af89e893e7
commit
1e5d9fd8c0
43
README.md
43
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?
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Puppeteer API v<!-- GEN:version -->0.1.0<!-- GEN:stop-->
|
||||
# Puppeteer API v<!-- GEN:version -->0.9.0<!-- GEN:stop-->
|
||||
|
||||
##### 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)
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "puppeteer",
|
||||
"version": "0.1.0",
|
||||
"version": "0.9.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"repository": "github:GoogleChrome/puppeteer",
|
||||
|
Loading…
Reference in New Issue
Block a user