puppeteer/utils/browser
Jack Franklin 6522e4f524
chore: Use expect for assertions (#5581)
Rather than use our own custom expect library, we can use expect from npm [1], which has an API almost identical to the one Puppeteer has, but with more options, better diffing, and is used by many in the community as it's the default assertions library that comes with Jest.

It's also thoroughly documented [2].

[1]: https://www.npmjs.com/package/expect
[2]: https://jestjs.io/docs/en/expect
2020-04-03 13:22:55 +02:00
..
README.md chore: update URLs (#5185) 2019-11-26 13:12:25 +01:00
test.js chore: Use expect for assertions (#5581) 2020-04-03 13:22:55 +02: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/puppeteer/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/puppeteer/puppeteer/issues/3455.