puppeteer/utils/browser
2019-01-18 17:33:34 -08:00
..
README.md docs(troubleshooting): fix bundle directions (#3808) 2019-01-18 17:33:34 -08:00
test.js test: setup sandbox on linux (#3530) 2018-11-12 23:26:16 -08:00
WebSocket.js chore: make sure Puppeteer bundling works (#3239) 2018-09-13 20:08:51 +01:00

Bundling For Web Browsers

To bundle Puppeteer using Browserify:

  1. Clone Puppeteer repository: git clone https://github.com/GoogleChrome/puppeteer && cd puppeteer
  2. npm install
  3. Run npm run bundle

This will create ./utils/browser/puppeteer-web.js file that contains Puppeteer bundle.

You can use it later on in your web page to drive another browser instance through its WS Endpoint:

<script src='./puppeteer-web.js'></script>
<script>
  const puppeteer = require('puppeteer');
  const browser = await puppeteer.connect({
    browserWSEndpoint: '<another-browser-ws-endpont>'
  });
  // ... drive automation ...
</script>

See our puppeteer-web tests for details.

Running inside Chrome Extension

You might want to enable unsafe-eval inside the extension by adding the following to your manifest.json file:

"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"

Please see discussion in https://github.com/GoogleChrome/puppeteer/issues/3455.