Bucklescript bindings for Puppeteer (headless chrome browser) written in Reason
npm install bs-puppeteerBuckleScript bindings to
Puppeteer
(the Headless Chrome Node API)
written in ReasonML.
This allows programmatic control of an instance of the Chrome or Chromium browser
from BuckleScript or Reason.



These bindings are a work in progress.
Most bindings for navigation and interaction with web pages have been implemented.
There may be some minor breaking changes as we refine the API.
Bindings to the page events API are planned for a future version.
See examples and the test suite
for examples of usage.
Features of the Puppeteer API are implemented as we need or get to them.
We do our best to track upstream API changes.
If you would like to add or fix some bindings, see Contributing.
Changes are documented in HISTORY.md.
Create a new BuckleScript project if you have not already:
``sh`
bsb -init my-project -theme basic-reason
cd my-project
See the
BuckleScript documentation
for more information about starting a project.
Add bs-puppeteer as a dependency.
This will install the currently supported version of Puppeteer.
`sh`
yarn
yarn add bs-puppeteer
Edit your bsconfig.json file to add bs-puppeteer to bs-dependencies:
`sh`
"bs-dependencies" : [
"bs-puppeteer",
],
Now run:
`sh`
yarn startstart
While the command is running, it will attempt to recompile your code each time you save it.yarn build
One-off builds can be done with .
The BsPuppeteer module should now be available in your source files.BsPuppeteer.Puppeteer.launch()
You can launch a new browser instance using .
See the examples for a more detailed demonstration.
For interacting with the DOM on pages you navigate to we recommend using
bs-webapi.
Contributions are welcome.
Get started by cloning the respository and starting the compiler in watch mode.
We recommend using yarn, but npm should also work.
`sh`
git clone https://github.com/zploskey/bs-puppeteer.git
cd bs-puppeteer
yarn
yarn start
Any changes should pass the test suite (yarn test).__tests__
One great way to contribute is by writing tests for features that don't yet have them.
Tests can be found in the directory.refmt
A git hook will automatically run on your code and run the test suite each time you commit.
If you would like to see a diff of the compiled javascript code from your changes,
you can take a snapshot of the built JS you would like to compare to with our snapsnap-diff
and package commands.
A typical workflow might look like this:
`sh`
git checkout master # you may want to stash any changes with git stash
yarn snap # snapshot the built JS to the snap/ directoryedit the code to make whatever changes
yarn snap-diff
This should rebuild and display git diff --no-index output comparing lib/js and snap/js`.
This can be handy in making sure that the right code is being generated.
Good references for contributing to this library are:
- BuckleScript Interop Cheatsheet
- Puppeteer API Docs