Skip to content

Commit

Permalink
Merge pull request #27 from paypal/develop
Browse files Browse the repository at this point in the history
merge develop (0.3.x) to master
  • Loading branch information
nikulkarni committed Jan 21, 2015
2 parents 9b28e80 + ba60885 commit ad6a0ee
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function (grunt) {
globals: ['should'],
timeout: 30000,
ignoreLeaks: false,
grep: '',
grep: grunt.option('grep') || '',
ui: 'bdd',
reporter: 'spec'
},
Expand Down
39 changes: 28 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ For a holistic guide to using Nemo as an overall automation solution, [please st
add the following to package.json devDependencies (assuming mocha is already integrated to your project):

```javascript
"nemo": "^0.2.1",
"nemo": "^0.3.1",
```

Then `npm install`
Expand All @@ -38,7 +38,7 @@ var Nemo = require("../");
process.env.nemoData = JSON.stringify({
targetBrowser: "firefox",
targetServer: "localhost",
serverProps: {"port": 4444},
localServer: true,
seleniumJar: "/usr/bin/selenium-server-standalone.jar",
targetBaseUrl: "https://www.paypal.com"
});
Expand All @@ -48,9 +48,7 @@ var config = {
nemoData: {
targetBrowser: "firefox",
targetServer: "localhost",
serverProps: {
"port": 4444
},
localServer: true,
seleniumJar: "/usr/bin/selenium-server-standalone.jar",
targetBaseUrl: "https://www.paypal.com"
}
Expand All @@ -68,7 +66,7 @@ var config = {
```

You can see this file within the nemo examples directory:
https://github.com/paypal/nemo/examples/setup.js
[https://github.com/paypal/nemo/examples/setup.js](/examples/setup.js)

Note you can set `nemoData` via an environment variable OR by passing it into the Nemo constructor.

Expand Down Expand Up @@ -101,17 +99,20 @@ which need to require modules from your test suite.

Browser you wish to automate. Make sure that your chosen webdriver has this browser option available

### targetServer (optional/conditional)
### localServer (optional, defaults to false)

Set localServer to true if you want Nemo to attempt to start a standalone binary on your system (like selenium-standalone-server) or use a local browser/driver like Chrome/chromedriver or PhantomJS.


### targetServer (optional)

Webdriver server you wish to use. Set as simply "localhost" if you are using a selenium-standalone driver on your local machine.
Leave unset if you are using chrome or phantomjs on your local machine
Webdriver server URL you wish to use.

If you are using sauce labs, make sure `targetServer` is set to correct url like `"http://yourkey:[email protected]:80/wd/hub"`

### serverProps (optional/conditional)

Additional server properties required of the 'targetServer'. If you are using a selenium-standalone driver on your local machine,
you have to minimally specify the port number. Leave unset if you aren't specifying a targetServer.
Additional server properties required of the 'targetServer'

You can also set args and jvmArgs to the selenium jar process as follows:

Expand Down Expand Up @@ -186,6 +187,22 @@ More on plugin authoring can be found here: https://github.com/paypal/nemo-docs/

File issues for new plugin creation here: https://github.com/paypal/nemo-plugin-registry/issues

## Logging and debugging

Nemo uses the [debug](https://github.com/visionmedia/debug.git) module for console logging and error output. There are two classes of logging, `nemo:log` and `nemo:error`

If you want to see both classes of output, simply use the appropriate value of the DEBUG environment variable when you run nemo:

```bash
$ DEBUG=nemo:* <nemo command>
```

To see just one:

```bash
$ DEBUG=nemo:error <nemo command>
```

## API

### Nemo constructor
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "nemo",
"version": "0.2.6",
"version": "0.3.1",
"description": "Abstraction for automation test components",
"scripts": {
"test": "grunt"
"test": "grunt --grep @travis@"
},
"dependencies": {
"selenium-webdriver": "~2.42.0",
"selenium-webdriver": "~2.44.0",
"xunit-file": "~0.0.4",
"debug": "^2.1.0",
"async": "0.1.x",
"nconf": "~0.6.7",
"lodash": "^2.4.0"
Expand All @@ -16,7 +17,6 @@
"devDependencies": {
"async": "~0.2.8",
"chai": "~1.6.0",
"debug": "^2.1.0",
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.7.1",
"grunt-loop-mocha": "^0.3.0",
Expand Down
25 changes: 15 additions & 10 deletions setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,32 @@ function Setup() {
return {
doSetup: function doSetup(_wd, nemoData, callback) {
log('entering doSetup');
if (nemoData === {} || nemoData.targetBrowser === undefined) {
callback(new Error('[Nemo::doSetup] The nemoData environment variable is missing or not fully defined! Please read about nemoData configuration here: https://github.com/paypal/nemo/blob/master/README.md#nemo-configuration'));
if (nemoData === {}) {
callback(new Error('[Nemo::doSetup] The nemoData environment variable is missing or not fully defined!'));
return;
}
var caps,
tgtBrowser = nemoData.targetBrowser,
tgtBrowser = nemoData.targetBrowser || '',
localServer = nemoData.localServer || false,
customCaps = nemoData.serverCaps,
serverUrl = nemoData.targetServer,
serverProps = nemoData.serverProps,
serverProps = nemoData.serverProps || {},
serverJar = nemoData.seleniumJar,
errorObject = null;

function getServer() {
log('attempt getServer');
if (serverProps && (serverUrl.indexOf('127.0.0.1') !== -1 || serverUrl.indexOf('localhost') !== -1)) {
log('attempt server startup');
//chrome and phantomjs are supported natively. i.e. no webdriver required. chromedriver or phantomjs executables must be in PATH though
//are we running the tests on the local machine?
if (localServer === true) {
log('test locally');
if (tgtBrowser !== 'chrome' && tgtBrowser !== 'phantomjs') {
//make sure there is a jar file
var jarExists = fs.existsSync(serverJar);
if (!jarExists) {
throw new Error('You must specify a valid SELENIUM_JAR value. The value must point to a driver executable in your file system.');
error('You must specify a valid SELENIUM_JAR value. The value must point to a driver executable in your file system.');
}
if (serverProps.port === undefined) {
serverProps.port = 4444;
}
var server = new SeleniumServer(serverJar, serverProps);
server.start();
Expand All @@ -66,7 +70,8 @@ function Setup() {
function getCapabilities() {
//specified valid webdriver browser key?
if (!webdriver.Capabilities[tgtBrowser]) {
error('You have specified ' + tgtBrowser + ' which is an invalid webdriver.Capabilities browser option');
log('You have specified targetBrowser: ' + tgtBrowser + ' which is not a built-in webdriver.Capabilities browser option');
caps = new webdriver.Capabilities();

} else {
caps = webdriver.Capabilities[tgtBrowser]();
Expand All @@ -76,7 +81,7 @@ function Setup() {
caps.set(key, customCaps[key]);
});
}

log('Capabilities', caps);
return caps;
}

Expand Down
95 changes: 95 additions & 0 deletions test/test-nemoData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/* global module: true, require: true, console: true */
"use strict";

var should = require('chai').should(),
Nemo = require('../index');

describe("@nemoData@ suite", function () {
var nemo;
describe("@environmentVariable@", function () {
before(function (done) {
process.env.nemoData = JSON.stringify({
targetBrowser: "firefox",
localServer: true,
seleniumJar: "/usr/local/bin/selenium-server-standalone.jar",
targetBaseUrl: "https://www.paypal.com",
passThroughFromEnv: true
});
done();
});
after(function (done) {
nemo.driver.quit().then(function () {
setTimeout(function() {done();}, 100);
});
});
it("should launch a local server and have the passThroughFromEnv variable", function (done) {
(new Nemo()).setup({}).then(function (_nemo) {
nemo = _nemo;
nemo.driver.get(nemo.props.targetBaseUrl).then(function () {
if (nemo.props.passThroughFromEnv === true) {
done();
} else {
done(new Error("some problem with passthrough variable"));
}
}, function (err) {
done(err);
});
});
});
});
describe("@jsonVariable@", function () {
after(function (done) {
nemo.driver.quit().then(function () {
setTimeout(function() {done();}, 100);
});
});
var nemoData = {
targetBrowser: "firefox",
localServer: true,
seleniumJar: "/usr/local/bin/selenium-server-standalone.jar",
targetBaseUrl: "https://www.paypal.com",
passThroughFromJson: true
};
var nemo;
it("should launch a local server and have the passThroughFromEnv variable", function (done) {
(new Nemo({nemoData: nemoData})).setup({}).then(function (_nemo) {
nemo = _nemo;
nemo.driver.get(nemo.props.targetBaseUrl).then(function () {
if (nemo.props.passThroughFromJson === true && nemo.props.passThroughFromEnv === undefined) {
done();
} else {
done(new Error("some problem with passthrough variable"));
}
}, function (err) {
done(err);
});
});
});
});
describe("@launchFirefox@", function () {
before(function (done) {
process.env.nemoData = JSON.stringify({
targetBrowser: "firefox",
targetBaseUrl: "https://www.paypal.com"
});
done();
});
after(function (done) {
nemo.driver.quit().then(function () {
setTimeout(function() {done();}, 10);
});
});
it("should work without localServer, seleniumJar props", function (done) {
(new Nemo()).setup({}).then(function (_nemo) {

nemo = _nemo;
console.log(nemo.props.targetBaseUrl);
nemo.driver.get(nemo.props.targetBaseUrl).then(function () {
done();
}, function (err) {
done(err);
});
});
});
});
});
6 changes: 3 additions & 3 deletions test/test-setup.js → test/test-travis.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
var should = require('chai').should(),
Nemo = require('../index');

describe("nemo functionality", function () {
describe("nemo @travis@ suite", function () {
var driver;
var nemo;
var config = require("./config/plugins");
Expand All @@ -25,7 +25,7 @@ describe("nemo functionality", function () {
_nemo.should.not.equal(undefined);
done();
});
it("should return back camelcase properties from titlecase ARGV options and also init any plugins", function (done) {
it("should return back nemoData properties and init any plugins", function (done) {
//console.log(_nemo.setup);
_nemo.setup({
"samplePlugin": {
Expand All @@ -47,7 +47,7 @@ describe("nemo functionality", function () {
done(err);
});
});
it("should navigate to the TARGET_BASE_URL set via command line", function (done) {
it("should navigate to the targetBaseUrl set via nemoData", function (done) {
driver.get(nemo.props.targetBaseUrl).
then(function () {
done();
Expand Down

0 comments on commit ad6a0ee

Please sign in to comment.