readme: add console event debugging tip (#481)

This commit is contained in:
Eric Bidelman 2017-08-22 20:17:09 -07:00 committed by Andrey Lushnikov
parent a526e9f9fb
commit 7e1f2f0609

View File

@ -120,6 +120,19 @@ Explore the [API documentation](docs/api.md) and [examples](https://github.com/G
}); });
``` ```
2. Capture console output from the page by listening for the `console` event.
This is also handy when debugging code in `page.evaluate()`:
```js
page.on('console', (...args) => {
console.log('PAGE LOG:', ...args);
});
await page.evaluate(() => {
console.log(`url is ${location.href}`);
});
```
## Contributing to Puppeteer ## Contributing to Puppeteer
Check out [contributing guide](https://github.com/GoogleChrome/puppeteer/blob/master/CONTRIBUTING.md) to get an overview of Puppeteer development. Check out [contributing guide](https://github.com/GoogleChrome/puppeteer/blob/master/CONTRIBUTING.md) to get an overview of Puppeteer development.