Getting started

Nemo can be combined with many plugins and test runners. Here is a recipe to combine nemo with nemo-view (handy webdriver abstractions and locator organization) and MochaJS (popular node.js unit testing framework).

The instructions assume you are running shell commands from within a node.js project with a package.json file and a test directory.

Installation

npm install --save-dev nemo nemo-view mocha
mkdir test
mkdir test/functional
mkdir test/functional/spec
touch test/functional/spec/first-spec.js
mkdir test/functional/config
touch test/functional/config/config.json

Create files

first-spec.js

/*global describe:true, it:true */

var basedir = require('path').resolve(__dirname, '..');
var Nemo = require('nemo');
var nemo;

describe('suite using @generic@ nemo-view methods', function () {
  before(function (done) {
    nemo = Nemo(basedir, function (err) {
      if (err) {
        return done(err);
      }
      done();
    });
  });
  after(function (done) {
    nemo.driver.quit().then(done);
  });
  it('should automate the browser', function (done) {
    //login
    nemo.driver.get(nemo.data.baseUrl);
    nemo.view._waitVisible('id:signup-button').click();
    nemo.view._waitVisible('id:cta-btn').click();
    nemo.view._waitVisible('id:email').sendKeys('mynewpaypalaccount@geemail.paypal');
    nemo.driver.sleep(3000).then(function () {
      done();
    }, function (err) {
      done(err);
    })
  });
});

config.json

{
  "plugins": {
    "view": {
      "module": "nemo-view",
      "arguments": ["path:locator"]
    }
  },
  "driver": {
    "browser": "firefox"
  },
  "data": {
    "baseUrl": "https://www.paypal.com"
  }
}

Run tests

node_modules/.bin/mocha test/functional/spec/*.js --timeout 30000 --reporter spec

Results

You should have seen a Firefox browser open, load paypal.com, and begin the personal account signup flow. If this didn't happen, some common issues/solutions are below:

Next steps

To build a substantial test suite, you will probably want to: