Example usage of Nemo automation for a node.js web application (using kraken-js)
It is recommended that you are running
node@v4 or above. If you are using
v0.12 for some reason, note that newer versions of selenium-webdriver
use ES6 features. You will need to make sure your node process is started with the
harmony flag. In general, it's best to use
node@v4 or newer.
If you plan to run the
wdb-spec.js test (it doesn't run by default), you will need to have an appropriate version of the selenium-standalone jar file on your system. Please see below for more information.
Install and start the application.
$ git clone https://github.com/paypal/nemo-example-app.git $ cd nemo-example-app $ npm install $ grunt build $ npm start
$ grunt automation
If you didn't get a successful test run, where you saw a browser open on your desktop, then please refer to this document for instructions on setting up a webdriver.
About the application
This application has one route: http://localhost:8000
It simulates a one-page app, with latency between navigations and simulated "add" operations, and success/failure messages printed to screen.
- successful login: provide any email address except "email@example.com"
- failed login: use "firstname.lastname@example.org"
- successful add card: provide any card number except 1001001
- failed add card: use 1001001
- successful add bank: provide any account number except 1001001
- failed add bank: use 1001001
As mentioned above, an identical application is hosted here: https://fast-castle-8102.herokuapp.com
Progression of automation tests
There are several suite files, each illustrating different things:
generic-spec.jsuses inline locator strings and generic
nemo-viewmethods (see here). Illustrates a first pass of automation.
view-spec.jsuses JSON locator files which
nemo-viewturns into convenience methods (see here). Illustrates a second pass of automation where inline locator strings are separated into JSON locator files.
page-spec.jsuses JSON locator files which nemo-page(like
nemo-view) uses to build a model to allow you to do element-level methods in a simple, concise, and precise way.
- You need selenium-standalone on your system. To get it, start here
- export the path to selenium-standalone as
- use the command
grunt loopmocha:wdbto start the wdb spec
flow/*.jsmodules to illustrate how to abstract functionality into shareable modules
util/index.jsmodule to abstract error handling and callback management
Getting feedback from your tests
The core nemo modules use the debug module for logging. It is fairly easy to get (or hide) the useful logging output.
If you want to see a good amount of logging information, set
nemo-logger module is installed to switch on the selenium-webdriver logging. The output can be quite verbose,
but if you need it, change the value of the plugin argument in the
test/functional/config/config.json file from
Using mocha directly
grunt auto runs mocha via the intermediate grunt-loop-mocha task.
Sometimes, for debugging purposes, it is nice to strip that layer away and run the tests via mocha directly. To do that
in this repo, do the following:
$ export nemoBaseDir=/path/to/this/repo/nemo-example-app/test/functional $ DEBUG=nemo*,selenium-drivex* $ node_modules/.bin/mocha test/functional/spec/*.js --timeout 30000 --grep @flow --harmony
DEBUG variable is optional, if you want to see a lot of logging during your tests
harmony flag is only necessary if you are using node < v4