Skip to content
This repository has been archived by the owner on Mar 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request #29 from joelgriffith/feature/graphql
Browse files Browse the repository at this point in the history
WOOHOO! GraphQL interface 🔥
  • Loading branch information
Joel Griffith committed Jul 19, 2017
2 parents c76c015 + 0aa4312 commit 3cec11c
Show file tree
Hide file tree
Showing 30 changed files with 1,347 additions and 142 deletions.
70 changes: 18 additions & 52 deletions README.md
Expand Up @@ -5,69 +5,35 @@
[![dependencies Status](https://david-dm.org/joelgriffith/navalia/status.svg)](https://david-dm.org/joelgriffith/navalia)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

`npm install --save navalia`

[View the documentation here](https://joelgriffith.github.io/navalia/)

Automate and scale browser workflows with a sane API. Navalia exports a handy `Navalia` module that acts as browser-load balancer, as well as a `Chrome` module that you can use for an easier experience.

## Usage

- [Functional Testing](https://codeburst.io/composable-end-to-end-tests-for-react-apps-2ec82170af62)
```bash
$ npm i -g navalia
$ navalia --port 5000
```

- [Website Code Coverage](https://codeburst.io/capturing-unused-application-code-2b7594a9fe06)
![NavaliaQL](./assets/NavaliaQL.gif)

**BETA WARNING**
This project heavily relies on bleeding-edge technology, as such the API and internals will likely change from time to time. I heavily recommend that you install `Chrome Canary` to capture the latest and greatest the browser has to offer.
Drive a headless browser with ease by using GraphQL. Navalia exposes both a GraphQL front-end and a set of modules for painless browser automation. There's no clunky API to learn or plugins to install.

## Features

- Runs and controls multiple instances of particular browser (currently Chrome).
- Scrape webpage data, even from JavaScript-heavy sites.
- Run automated functional tests.
- Discover visual regressions in your site.
- Capture screenshots, pdfs, execute javascript, insert text, and more.
- Queue work automatically when all instances are busy.
- Uses a simple, easy to understand API.
- Work can easily span over multiple pages or complex interactions.
- Set timers and max-jobs limitations on browsers, forcing them to reboot for easier memory management.
- Use any runtime or framework you want!

## Navalia Example
```javascript
// Navalia manages browser instances
// and can jobs can be queued against it
const { Navalia } = require('Navalia');
const navalia = new Navalia();
[View the library documentation here](https://joelgriffith.github.io/navalia/)

navalia.register((chrome) => {
return chrome.goto('http://www.google.com/')
.then(() => chrome.pdf('/Users/jgriffith/Downloads/google.pdf'));
});
[Install the npm module to run the GraphiQL client](https://www.npmjs.com/package/navalia)

navalia.register((chrome) => {
return chrome.goto('http://www.facebook.com/')
.then(() => chrome.pdf('/Users/jgriffith/Downloads/facebook.pdf'));
});
```

## Chrome Example
```ts
// Simple, easy to use Chrome wrapper
import { Chrome } from 'navalia';

const chrome = new Chrome();

async function screenshotHN() {
await chrome.goto('https://news.ycombinator.com/');
await chrome.click('a')
await chrome.wait(500);
await chrome.screenshot('/Users/jgriffith/Downloads/hn.png');
return chrome.done();
}
**BETA WARNING**
This project heavily relies on bleeding-edge technology, as such the API and internals will likely change from time to time. I heavily recommend that you install `Chrome Canary` to capture the latest and greatest the browser has to offer.

screenshotHN();
```
## Recipes

## More Examples
- [Functional Testing](https://codeburst.io/composable-end-to-end-tests-for-react-apps-2ec82170af62)

Looking for more? [Check out the docs](https://joelgriffith.github.io/navalia/).
- [Website Code Coverage](https://codeburst.io/capturing-unused-application-code-2b7594a9fe06)

## Roadmap

Expand All @@ -76,7 +42,7 @@ In no particular order, this is the vision of navalia going forward:
- [X] Expanded browser API (pdf rendering, network watching, more).
- [ ] Bring more vendors onto the framework.
- [ ] Better typings around externals with no @type support.
- [ ] Parameterization on killing long-running jobs.
- [X] Parameterization on killing long-running jobs.
- [ ] Unit testing all features.
- [ ] Integration testing with the various vendors so our API's don't break when theirs do.
- [X] Travis, coveralls, greenkeeper, and other handy-dandy tools to automate chore tasks.
Binary file added assets/NavaliaQL.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions bin/navalia.js
@@ -0,0 +1,5 @@
#!/usr/bin/env node
const { start } = require('../build/graphql/server');
const { argv } = require('yargs');

start(argv.port || 4000);
10 changes: 9 additions & 1 deletion package.json
Expand Up @@ -4,10 +4,14 @@
"description": "A browser automation manager with a consistent API",
"main": "build/index.js",
"types": "build/index.d.ts",
"bin": {
"navalia": "bin/navalia.js"
},
"scripts": {
"build": "npm run clean && tsc",
"clean": "rimraf build",
"cover": "jest --coverage",
"dev": "nodemon --watch 'src/**/*.ts' --ignore 'src/**/*.spec.ts' --exec 'ts-node' src/graphql/server.ts",
"docs": "cd docs && bundle exec jekyll serve",
"precommit": "lint-staged",
"prepublish": "npm run build",
Expand Down Expand Up @@ -44,8 +48,12 @@
"chrome-launcher": "^0.3.0",
"chrome-remote-interface": "^0.24.1",
"debug": "^2.6.8",
"express": "^4.15.3",
"express-graphql": "^0.6.6",
"graphql": "^0.10.5",
"lodash": "^4.17.4",
"ts-node": "^3.1.0"
"ts-node": "^3.1.0",
"yargs": "^8.0.2"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 3cec11c

Please sign in to comment.