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 startRun Nemo
$ grunt automationIf 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.
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 "fail@fail.com"
- failed login: use "fail@fail.com"
- 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
There are several suite files, each illustrating different things:
-
generic-spec.jsuses inline locator strings and genericnemo-viewmethods (see here). Illustrates a first pass of automation. -
view-spec.jsuses JSON locator files whichnemo-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(likenemo-view) uses to build a model to allow you to do element-level methods in a simple, concise, and precise way. -
wdb-spec.jsuses the nemo-wd-bridge plugin to provide the wd interface, for those who prefer it.- You need selenium-standalone on your system. To get it, start here
- export the path to selenium-standalone as
SELENIUM_STANDALONE_PATH=/path/to/selenium-standalone.jar - use the command
grunt loopmocha:wdbto start the wdb spec
-
flow-spec.js- uses
flow/*.jsmodules to illustrate how to abstract functionality into shareable modules - uses
util/index.jsmodule to abstract error handling and callback management
- uses
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 DEBUG=nemo*,selenium-drivex*.
Additionally, the 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 WARNING to ALL.
Using 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 --harmonyNote: the DEBUG variable is optional, if you want to see a lot of logging during your tests
Note: the harmony flag is only necessary if you are using node < v4