web-pilot

0.0.6 • Public • Published

WEB-PILOT

What it does

This module relies on Selenium WebDriver to automate tests.

how to install

npm install web-pilot

install selenium locally (optional)

  1. go to http://docs.seleniumhq.org/download/

  2. look for Selenium Server such as:

  3. look for DriversThird Party Browsers such as:

  4. move the downloads to a directory and extract compressed drivers
    you should have a chromedriver executable and the standalone jar

  5. create the bash script node.sh and chmod it executable chmod a+x node.sh:

#!/bin/bash
java -jar selenium-server-standalone-2.37.0.jar -role node -hub http://localhost:4444/grid/register
  1. create the bash script hub.sh and chmod it executable chmod a+x hub.sh:
#!/bin/bash
java -jar selenium-server-standalone-2.37.0.jar -role hub

run selenium grid locally (optional)

Run hub.sh and node.sh in a console:

./hub.sh  &
./node.sh &

configure web-pilot

The module exposes a factory function which supports the following options (and their defaults):

{
    debug:       false,
    verbose:     false,
    inParallel:  2,
    endpoint:    ['localhost', 4444],
    sauceFields: {}
}

It works with SauceLabs services. See here. Example config:

{
    debug:       false,
    endpoint:    ['ondemand.saucelabs.com', 80, 'SAUCEUSER', 'SAUCEKEY'],
    sauceFields: {name:'some unit test project name', build:'131130c', tags:['new', 'stuff']}
}

exposed API

The factory provides the following functions:

unit(profile, page, endCb);

units(profiles, pages, endCb, [progressCb]);

functional(profile, fn, endCb);

functionals(profiles, fns, endCb, [progressCb]);

A profile is an object defining environment restrictions such as platform, browserName and version.

A page is an HTTP URL. If using a grid such as SauceLabs' make sure the URLs are reachable. Unit tests expect pages with QUnit tests.

A fn receives a wd browser object, capabilities object and a callback which the functional test should call at end or error.

See here for additional information:

profiles, functions and pages are arrays of each.

Callbacks (endCb) use the standard (err, results) signature.

Callbacks progressCb use (err, result, done, total)

Check the sample directory in the github repository for example usages.

auxiliary stuff

I'm adding some auxiliary functions to aid in common tasks. For now these are in sample/aux.js. Once matured these may be promoted to web-pilot itself, we'll see.

Notice that aux requires the imagemagick npm module.

Most useful functions are:

  • aux.consoleUnitReport(results) - returns a summary of unit tests as a table

  • aux.consoleFunctionalReport(results) - returns a summary of functional tests as a table

  • aux.saveScreenshot(browser, filename, cb) - saves screenshot to filename

  • aux.saveElementImage(browser, element, filename, cb) - saves element representation to filename

Readme

Keywords

none

Package Sidebar

Install

npm i web-pilot

Weekly Downloads

1

Version

0.0.6

License

MIT

Last publish

Collaborators

  • josepedrodias