Comparing version 0.1.1 to 0.2.0
222
index.js
@@ -18,6 +18,9 @@ /*───────────────────────────────────────────────────────────────────────────*\ | ||
var async = require('async'), | ||
Setup = require('./setup'), | ||
nemoData = {}, | ||
_ = require('lodash'), | ||
webdriver = require('selenium-webdriver'); | ||
Setup = require('./setup'), | ||
nemoData = {}, | ||
waterFallArray = [], | ||
preDriverArray = [], | ||
postDriverArray = [], | ||
_ = require('lodash'), | ||
webdriver = require('selenium-webdriver'); | ||
@@ -33,116 +36,119 @@ /** | ||
//console.log('Nemo constructor config: ', config); | ||
this.plugins = {}; | ||
//config is for registering plugins | ||
if (config && config.plugins) { | ||
this.plugins = config.plugins; | ||
} | ||
this.plugins = {}; | ||
//config is for registering plugins | ||
if (config && config.plugins) { | ||
this.plugins = config.plugins; | ||
} | ||
} | ||
Nemo.prototype = { | ||
/** | ||
* | ||
* Nemo.setup | ||
*@param {Object} config - | ||
* { | ||
* 'view': ['example-login', 'serviceError'], //optional | ||
* 'locator': ['wallet'], //optional | ||
* } | ||
*@returns webdriver.promise - successful fulfillment will return an {Object} as below: | ||
* { | ||
* 'view': {}, //view instances if specified in config | ||
* 'locator': {}, //locator instances if specified in config | ||
* 'driver': {}, //driver instance. ALWAYS | ||
* 'wd': {}, //static reference to selenium-webdriver. ALWAYS | ||
* } | ||
*/ | ||
setup: function (config) { | ||
nemoData = JSON.parse(process.env.nemoData); | ||
config = config || {}; | ||
var that = this, | ||
returnObj = { | ||
'view': {}, | ||
'locator': {}, | ||
'driver': {}, | ||
'wd': {} | ||
}, | ||
d = webdriver.promise.defer(), | ||
waterFallArray = [driversetup]; | ||
/** | ||
* | ||
* Nemo.setup | ||
*@param {Object} config - | ||
* { | ||
* 'view': ['example-login', 'serviceError'] //optional | ||
* ,'locator': ['wallet'] //optional | ||
* ,<plugin config namespace>: <plugin config> //optional, depends on plugin setup | ||
* } | ||
*@returns webdriver.promise - successful fulfillment will return an {Object} as below: | ||
* { | ||
* 'view': {} //view instances if specified in config | ||
* ,'locator': {} //locator instances if specified in config | ||
* ,'driver': {} //driver instance. ALWAYS | ||
* ,'wd': {} //static reference to selenium-webdriver. ALWAYS | ||
* ,<plugin namespace>: <plugin object> //if plugin registers | ||
* } | ||
*/ | ||
setup: function(config) { | ||
nemoData = JSON.parse(process.env.nemoData); | ||
config = config || {}; | ||
var that = this, | ||
returnObj = { | ||
'props': nemoData, | ||
'view': {}, | ||
'locator': {}, | ||
'driver': {}, | ||
'wd': {} | ||
}, | ||
d = webdriver.promise.defer(), | ||
preDriverArray = [datasetup]; | ||
Object.keys(that.plugins).forEach(function (key) { | ||
var modulePath, | ||
pluginConfig, | ||
pluginModule; | ||
Object.keys(that.plugins).forEach(function(key) { | ||
var modulePath, | ||
pluginConfig, | ||
pluginModule; | ||
if ((that.plugins[key].register || config[key]) && key !== 'view') { | ||
//register this plugin | ||
pluginConfig = that.plugins[key]; | ||
modulePath = pluginConfig.module; | ||
pluginModule = require(modulePath); | ||
waterFallArray.push(pluginModule.setup); | ||
} | ||
}); | ||
if (config.view) { | ||
waterFallArray.push(viewsetup); | ||
} | ||
if (config.locator) { | ||
waterFallArray.push(locatorsetup); | ||
} | ||
async.waterfall(waterFallArray, function (err, result) { | ||
//console.log('waterfall result: ', result); | ||
if (err) { | ||
d.reject(err); | ||
} else { | ||
d.fulfill(returnObj); | ||
} | ||
}); | ||
return d; | ||
if ((that.plugins[key].register || config[key]) && key !== 'view') { | ||
//register this plugin | ||
pluginConfig = that.plugins[key]; | ||
modulePath = pluginConfig.module; | ||
pluginModule = require(modulePath); | ||
if (that.plugins[key].priority && that.plugins[key].priority < 100) { | ||
preDriverArray.push(pluginModule.setup); | ||
} else { | ||
postDriverArray.push(pluginModule.setup); | ||
} | ||
} | ||
}); | ||
waterFallArray = preDriverArray.concat([driversetup], postDriverArray); | ||
if (config.view) { | ||
waterFallArray.push(viewsetup); | ||
} | ||
if (config.locator) { | ||
waterFallArray.push(locatorsetup); | ||
} | ||
async.waterfall(waterFallArray, function(err, result) { | ||
if (err) { | ||
d.reject(err); | ||
} else { | ||
d.fulfill(returnObj); | ||
} | ||
}); | ||
return d; | ||
//waterfall functions | ||
//waterfall functions | ||
function datasetup(callback) { | ||
callback(null, config, returnObj); | ||
} | ||
function driversetup(config, result, callback) { | ||
//do driver/view/locator/vars setup | ||
(new Setup()).doSetup(webdriver, result.props, function(err, result) { | ||
if (err) { | ||
callback(err); | ||
} else { | ||
//set driver | ||
returnObj.driver = result.driver; | ||
returnObj.wd = webdriver; | ||
callback(null, config, returnObj); | ||
} | ||
}); | ||
} | ||
function driversetup(callback) { | ||
var toCamelCase = function (match, group1) { | ||
return group1.toUpperCase(); | ||
}; | ||
//do driver/view/locator/vars setup | ||
(new Setup()).doSetup(webdriver, function (err, result) { | ||
if (err) { | ||
callback(err); | ||
} else { | ||
//set driver | ||
returnObj.driver = result.driver; | ||
returnObj.wd = webdriver; | ||
returnObj.props = nemoData; | ||
callback(null, config, returnObj); | ||
} | ||
}); | ||
} | ||
function locatorsetup(config, result, callback) { | ||
//setup locators | ||
config.locator.forEach(function(key) { | ||
returnObj.locator[key] = require(returnObj.props.autoBaseDir + '/locator/' + key); | ||
}); | ||
callback(null, config, returnObj); | ||
} | ||
function locatorsetup(config, result, callback) { | ||
//setup locators | ||
config.locator.forEach(function (key) { | ||
returnObj.locator[key] = require(returnObj.props.autoBaseDir + '/locator/' + key); | ||
}); | ||
callback(null, config, returnObj); | ||
} | ||
function viewsetup(config, result, callback) { | ||
var viewConfig = result; | ||
//setup views | ||
config.view.forEach(function(key) { | ||
if (that.plugins.view) { | ||
//process with the view interface | ||
returnObj.view[(key.constructor === String) ? key : key.name] = require(that.plugins.view.module).addView(key, result); | ||
} else { | ||
var viewMod = require(returnObj.props.autoBaseDir + '/view/' + key); | ||
returnObj.view[key] = new viewMod(viewConfig); | ||
} | ||
function viewsetup(config, result, callback) { | ||
var viewConfig = result; | ||
//setup views | ||
config.view.forEach(function (key) { | ||
//console.log('key is: ' + key) | ||
if (that.plugins.view) { | ||
//process with the view interface | ||
returnObj.view[(key.constructor === String) ? key : key.name] = require(that.plugins.view.module).addView(key, result); | ||
} else { | ||
var viewMod = require(returnObj.props.autoBaseDir + '/view/' + key); | ||
returnObj.view[key] = new viewMod(viewConfig); | ||
} | ||
}); | ||
callback(null, config, returnObj); | ||
} | ||
} | ||
}); | ||
callback(null, config, returnObj); | ||
} | ||
} | ||
}; | ||
module.exports = Nemo; | ||
module.exports = Nemo; |
{ | ||
"name": "nemo", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Abstraction for automation test components", | ||
@@ -5,0 +5,0 @@ "scripts": { |
# Nemo | ||
[![Build Status](https://travis-ci.org/paypal/nemo.svg)](https://travis-ci.org/paypal/nemo) | ||
Nemo provides a simple way to add selenium automation to your NodeJS web projects. Provides plugin architecture to | ||
@@ -11,3 +13,2 @@ incorporate custom features to your tests. | ||
[![Build Status](https://magnum.travis-ci.com/paypal/nemo.svg?token=wkfLgEAgy8eZBxUbnTsB&branch=master)](https://magnum.travis-ci.com/paypal/nemo) | ||
@@ -27,3 +28,3 @@ ## Getting started | ||
```javascript | ||
"nemo": "git://github.com/paypal/nemo.git#master", | ||
"nemo": "^0.1.0", | ||
``` | ||
@@ -100,2 +101,12 @@ | ||
You can also set args and jvmArgs to the selenium jar process as follows: | ||
```javascript | ||
'serverProps': { | ||
'port': 4444, | ||
'args': ['-firefoxProfileTemplate','/Users/medelman/Desktop/ffprofiles'], | ||
'jvmArgs': ['-someJvmArg', 'someJvmArgValue'] | ||
} | ||
``` | ||
### seleniumJar (optional/conditional) | ||
@@ -105,2 +116,76 @@ | ||
### serverCaps (optional) | ||
serverCaps would map to the capabilities here: http://selenium.googlecode.com/git/docs/api/javascript/source/lib/webdriver/capabilities.js.src.html | ||
Some webdrivers (for instance ios-driver, or appium) would have additional capabilities which can be set via this variable. As an example, you can connect to saucelabs by adding this serverCaps: | ||
```javascript | ||
"serverCaps": { | ||
"username": "medelman", | ||
"accessKey": "b38e179e-079a-417d-beb8-xyz" //not my real access key | ||
} | ||
``` | ||
## API | ||
### Nemo constructor | ||
```javascript | ||
/** | ||
* Represents a Nemo instance | ||
* @constructor | ||
* @param {Object} config - Object which contains any plugin registration | ||
* | ||
*/ | ||
``` | ||
### Nemo.setup | ||
```javascript | ||
/** | ||
* | ||
* Nemo.setup | ||
*@param {Object} config - | ||
* { | ||
* 'view': ['example-login', 'serviceError'] //optional | ||
* ,'locator': ['wallet'] //optional | ||
* ,<plugin config namespace>: <plugin config> //optional, depends on plugin setup | ||
* } | ||
*@returns webdriver.promise - successful fulfillment will return an {Object} as below: | ||
* { | ||
* 'view': {} //view instances if specified in config | ||
* ,'locator': {} //locator instances if specified in config | ||
* ,'driver': {} //driver instance. ALWAYS | ||
* ,'wd': {} //static reference to selenium-webdriver. ALWAYS | ||
* ,<plugin namespace>: <plugin object> //if plugin registers | ||
* } | ||
*/ | ||
``` | ||
## Breaking down the setup method | ||
When you call 'setup' on a Nemo instance, what happens? The answer is important if you plan to write your own plugins or place Nemo in a new context outside of the examples already provided. Here is a plain English description of what happens: | ||
1. caller calls Nemo.setup(obj), obj being optional for when you are passing in plugins and/or plugin config | ||
2. Nemo.setup unpacks the nemoData environment variable, converts it to a JSON object | ||
3. Nemo.setup creates a return object (returnObj), and assigns the nemoData JSON data to the returnObj.props namespace | ||
2. Nemo.setup creates an array (waterFallArray) of setup functions, with the first one being 'driversetup' | ||
* driversetup will instantiate the selenium-webdriver session, and add it to 'result' as result.driver | ||
* driversetup will also add the selenium-webdriver module as result.wd (so other components can access the module) | ||
3. Nemo.setup loops through the 'obj.plugins' object, if passed in, and adds each plugin's 'setup' method to waterFallArray | ||
* each plugin (besides a 'view' plugin) must have a 'setup' method with signature (config, result, callback) | ||
* the 'setup' method may add an object to the 'result' namespace | ||
* the 'setup' method must call the callback function with config and result | ||
4. Nemo.setup adds 'viewsetup' to the waterFallArray, if obj.view was passed in | ||
* viewsetup will add result.view.<current view name> object for each string element in the obj.view array | ||
* if a 'view' plugin was specified, then Nemo will defer to that plugins 'addView' method | ||
* if no 'view' plugin was specified, then Nemo will look for modules in the targetBaseDir/view/ directory | ||
5. Nemo.setup adds 'locatorsetup' to the waterFallArray, if obj.locator was passed in | ||
* locatorsetup will add result.locator.<current locator name> for each string element in the obj.locator array | ||
6. Nemo.setup executes the waterFallArray methods using async.waterfall | ||
7. Nemo.setup returns a selenium-webdriver promise to the caller | ||
7. Each waterFallArray method, including the plugin setup methods, has the signature (config, result, callback) | ||
8. Each waterFallArray method can add to the 'result' object, and must pass along the config and result object in the callback | ||
9. The final callback in async.waterfall fulfills the promise from step 7, passing along the final 'result' object | ||
## Why Nemo? | ||
@@ -107,0 +192,0 @@ |
@@ -18,73 +18,71 @@ /*───────────────────────────────────────────────────────────────────────────*\ | ||
var fs = require('fs'), | ||
webdriver = require('selenium-webdriver'), | ||
SeleniumServer = require('selenium-webdriver/remote').SeleniumServer, | ||
nemoData = {}, | ||
driver; | ||
webdriver = require('selenium-webdriver'), | ||
SeleniumServer = require('selenium-webdriver/remote').SeleniumServer, | ||
nemoData = {}, | ||
driver; | ||
var Setup = function() { | ||
//constructor | ||
//constructor | ||
}; | ||
Setup.prototype = { | ||
doSetup: function(_wd, callback) { | ||
//look for nemoData env variable, error out if missing | ||
nemoData = JSON.parse(process.env.nemoData || {}); | ||
if (nemoData === {} || nemoData.targetBrowser === undefined) { | ||
callback(new Error('[Nemo::doSetup] The nemoData environment variable is missing or not fully defined!')); | ||
return; | ||
} | ||
var caps, | ||
tgtBrowser = nemoData.targetBrowser, | ||
customCaps = nemoData.serverCaps, | ||
serverUrl = nemoData.targetServer, | ||
serverProps = nemoData.serverProps, | ||
serverJar = nemoData.seleniumJar, | ||
errorObject = null; | ||
doSetup: function(_wd, nemoData, callback) { | ||
if (nemoData === {} || nemoData.targetBrowser === undefined) { | ||
callback(new Error('[Nemo::doSetup] The nemoData environment variable is missing or not fully defined!')); | ||
return; | ||
} | ||
var caps, | ||
tgtBrowser = nemoData.targetBrowser, | ||
customCaps = nemoData.serverCaps, | ||
serverUrl = nemoData.targetServer, | ||
serverProps = nemoData.serverProps, | ||
serverJar = nemoData.seleniumJar, | ||
errorObject = null; | ||
function getServer() { | ||
if (serverProps && (serverUrl.indexOf('127.0.0.1') !== -1 || serverUrl.indexOf('localhost') !== -1)) { | ||
//chrome and phantomjs are supported natively. i.e. no webdriver required. chromedriver or phantomjs executables must be in PATH though | ||
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.'); | ||
} | ||
var server = new SeleniumServer(serverJar, serverProps); | ||
server.start(); | ||
serverUrl = server.address(); | ||
} else { | ||
serverUrl = null; | ||
} | ||
} | ||
return serverUrl; | ||
} | ||
function getServer() { | ||
if (serverProps && (serverUrl.indexOf('127.0.0.1') !== -1 || serverUrl.indexOf('localhost') !== -1)) { | ||
//chrome and phantomjs are supported natively. i.e. no webdriver required. chromedriver or phantomjs executables must be in PATH though | ||
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.'); | ||
} | ||
var server = new SeleniumServer(serverJar, serverProps); | ||
server.start(); | ||
serverUrl = server.address(); | ||
} else { | ||
serverUrl = null; | ||
} | ||
} | ||
return serverUrl; | ||
} | ||
function getCapabilities() { | ||
//exception handling | ||
if (!webdriver.Capabilities[tgtBrowser]) { | ||
throw new TypeError('You have specified ' + tgtBrowser + ' which is an invalid browser option'); | ||
} | ||
caps = new webdriver.Capabilities(); | ||
function getCapabilities() { | ||
//exception handling | ||
if (!webdriver.Capabilities[tgtBrowser]) { | ||
throw new TypeError('You have specified ' + tgtBrowser + ' which is an invalid browser option'); | ||
} | ||
caps = new webdriver.Capabilities(); | ||
if (customCaps) { | ||
Object.keys(customCaps).forEach(function(key) { | ||
caps.set(key, customCaps[key]); | ||
}); | ||
} | ||
caps.merge(webdriver.Capabilities[tgtBrowser]()); | ||
return caps; | ||
} | ||
if (customCaps) { | ||
Object.keys(customCaps).forEach(function(key) { | ||
caps.set(key, customCaps[key]); | ||
}); | ||
} | ||
caps.merge(webdriver.Capabilities[tgtBrowser]()); | ||
return caps; | ||
} | ||
try { | ||
driver = new _wd.Builder(). | ||
usingServer(getServer()). | ||
withCapabilities(getCapabilities()).build(); | ||
} catch (err) { | ||
errorObject = err; | ||
} | ||
callback(errorObject, { | ||
'driver': driver | ||
}); | ||
} | ||
try { | ||
driver = new _wd.Builder(). | ||
usingServer(getServer()). | ||
withCapabilities(getCapabilities()).build(); | ||
} catch (err) { | ||
errorObject = err; | ||
} | ||
callback(errorObject, { | ||
'driver': driver | ||
}); | ||
} | ||
}; | ||
module.exports = Setup; | ||
module.exports = Setup; |
before(function(done) { | ||
console.log("doing before"); | ||
process.env.nemoData = JSON.stringify({ | ||
"autoBaseDir": process.cwd() + "/test", | ||
"targetBrowser": "firefox", | ||
"targetServer": "http://127.0.0.1:4444/wd/hub", | ||
"targetBaseUrl": "https://www.paypal.com", | ||
"seleniumJar": "/usr/bin/selenium-server-standalone.jar", | ||
"serverProps": {"port": 4444}, | ||
"locale": "FR" | ||
}); | ||
console.log(process.env.nemoData); | ||
done(); | ||
}); | ||
process.env.nemoData = JSON.stringify({ | ||
"autoBaseDir": process.cwd() + "/test", | ||
"targetBrowser": "phantomjs", | ||
//"targetServer": "http://127.0.0.1:4444/wd/hub", | ||
"targetBaseUrl": "https://www.paypal.com", | ||
//"seleniumJar": "/usr/bin/selenium-server-standalone.jar", | ||
//"serverProps": {"port": 4444}, | ||
"locale": "FR" | ||
}); | ||
done(); | ||
}); |
{ | ||
"plugins": { | ||
"samplePlugin": { | ||
"module": "./test/plugin/sample-plugin" | ||
"module": "./test/plugin/sample-plugin", | ||
"priority": 99 | ||
}, | ||
@@ -6,0 +7,0 @@ "drivex": { |
{ | ||
"cityOption": { | ||
"default": { | ||
"locator": "select[name='ddlTown'] option[value='Swindon']", | ||
"type": "css" | ||
} , | ||
"FR": { | ||
"locator": "select[name='ddlTown'] option[value='Burkino Faso']", | ||
"type": "css" | ||
} | ||
}, | ||
"noFRyesDefault": { | ||
"default": { | ||
"locator": "defaultId", | ||
"type": "id" | ||
} | ||
}, | ||
"noFRnoDefault": { | ||
"locator": "onlyId", | ||
"type": "id" | ||
} | ||
} | ||
"fname": { | ||
"locator": "first-name", | ||
"type": "id" | ||
}, | ||
"lname": { | ||
"locator": "last-name", | ||
"type": "id" | ||
}, | ||
"bmonth": { | ||
"locator": "month", | ||
"type": "id" | ||
}, | ||
"bday": { | ||
"locator": "day", | ||
"type": "id" | ||
}, | ||
"byear": { | ||
"locator": "year", | ||
"type": "id" | ||
}, | ||
"maleradio": { | ||
"locator": "label[for='male']", | ||
"type": "css" | ||
}, | ||
"cityOption": { | ||
"default": { | ||
"locator": "select[name='ddlTown'] option[value='Swindon']", | ||
"type": "css" | ||
} , | ||
"FR": { | ||
"locator": "select[name='ddlTown'] option[value='Burkino Faso']", | ||
"type": "css" | ||
} | ||
}, | ||
"noFRyesDefault": { | ||
"default": { | ||
"locator": "defaultId", | ||
"type": "id" | ||
} | ||
}, | ||
"noFRnoDefault": { | ||
"locator": "onlyId", | ||
"type": "id" | ||
} | ||
} |
@@ -6,3 +6,5 @@ var async = require("async"); | ||
var returnObj = result; | ||
returnObj.autoRegPlugin = true; | ||
returnObj.autoRegPlugin = {}; | ||
returnObj.autoRegPlugin.isDriverSetup = (returnObj.driver.get !== undefined); | ||
//array for waterfall methods | ||
@@ -9,0 +11,0 @@ var sampleCalls = [ |
var async = require("async"); | ||
module.exports = { | ||
"setup": function(config, result, callback) { | ||
//console.log(config); | ||
//console.log(result.driver); | ||
var returnObj = result; | ||
returnObj.samplePlugin = config.samplePlugin; | ||
returnObj.samplePlugin.isDriverSetup = (returnObj.driver.get !== undefined); | ||
returnObj.props.fromSamplePlugin = true; | ||
//array for waterfall methods | ||
@@ -8,0 +10,0 @@ var sampleCalls = [ |
@@ -5,128 +5,140 @@ /* global module: true, require: true, console: true */ | ||
var should = require('chai').should(), | ||
Nemo = require('../index'), | ||
nemo; | ||
Nemo = require('../index'), | ||
nemo; | ||
describe("nemo setup", function () { | ||
var driver; | ||
var config = require("./config/plugins"); | ||
var _nemo = new Nemo(config); | ||
describe("nemo setup", function() { | ||
var driver; | ||
var config = require("./config/plugins"); | ||
var _nemo = new Nemo(config); | ||
after(function (done) { | ||
driver.quit().then(function () { | ||
done(); | ||
}); | ||
}); | ||
it("should create a new instance", function (done) { | ||
_nemo.should.not.equal(undefined); | ||
done(); | ||
}); | ||
it("should return back camelcase properties from titlecase ARGV options and also init any plugins", function (done) { | ||
//console.log(_nemo.setup); | ||
var su = _nemo.setup({ | ||
"samplePlugin": { | ||
"sampleoptions": { | ||
"option1": "value1", | ||
"option2": "value2" | ||
} | ||
}, | ||
"locator": ["myView"], | ||
"view": ["myView", "myOtherView"] | ||
}); | ||
//console.log(su) | ||
su.then(function (result) { | ||
nemo = result; | ||
nemo.props.targetBrowser.should.equal("firefox"); | ||
nemo.props.targetServer.should.equal("http://127.0.0.1:4444/wd/hub"); | ||
nemo.props.targetBaseUrl.should.equal("https://www.paypal.com"); | ||
//nemo.noValue.should.equal(true); | ||
nemo.samplePlugin.sampleoptions.option1.should.equal("value1"); | ||
nemo.autoRegPlugin.should.equal(true); | ||
driver = nemo.driver; | ||
done(); | ||
}, function (err) { | ||
done(err); | ||
}); | ||
}); | ||
it("should navigate to the TARGET_BASE_URL set via command line", function (done) { | ||
driver.get(nemo.props.targetBaseUrl). | ||
then(function () { | ||
done(); | ||
}, function (err) { | ||
done(err); | ||
}); | ||
}); | ||
describe("nemo.locator", function () { | ||
it("should have pulled in the myView locator", function (done) { | ||
if (!nemo.locator.myView) { | ||
done(new Error("didn't get the locator")); | ||
} else { | ||
done(); | ||
} | ||
}); | ||
it("should get the FR locator when locale is FR", function (done) { | ||
if (nemo.props.locale === "FR" && nemo.locatex("myView.cityOption").locator === "select[name='ddlTown'] option[value='Burkino Faso']") { | ||
done(); | ||
} else { | ||
done(new Error("didn't get an FR flavored locator")); | ||
} | ||
}); | ||
it("should get the default locator when locale is FR and no FR locator", function (done) { | ||
if (nemo.props.locale === "FR" && nemo.locatex("myView.noFRyesDefault").locator === "defaultId") { | ||
done(); | ||
} else { | ||
done(new Error("didn't get an default flavored locator")); | ||
} | ||
}); | ||
it("should get the single locator when no locale-specific or default locator", function (done) { | ||
if (nemo.props.locale === "FR" && nemo.locatex("myView.noFRnoDefault").locator === "onlyId") { | ||
done(); | ||
} else { | ||
done(new Error("didn't get a non-flavored locator")); | ||
} | ||
}); | ||
}); | ||
describe("nemo.view", function () { | ||
it("should have the view methods available", function (done) { | ||
if (nemo.view.myView && nemo.view.myView.cityOption && nemo.view.myView.cityOption.constructor === Function) { | ||
done(); | ||
} else { | ||
done(new Error("didn't get the view method")); | ||
} | ||
}); | ||
it("should use the view methods", function(done) { | ||
nemo.driver.get("http://accessify.com/features/tutorials/accessible-forms/form-examples.htm"); | ||
nemo.view.myView.cityOptionPresent(). | ||
then(function (present) { | ||
nemo.view.myView.cityOption().click(); | ||
}). | ||
then(function () { | ||
driver.sleep(4000); | ||
}). | ||
then(function () { | ||
done(); | ||
}); | ||
}); | ||
// it("should use the view and subview interface methods", function (done) { | ||
// nemo.driver.get("http://accessify.com/features/tutorials/accessible-forms/form-examples.htm"); | ||
// nemo.view.myView.cityOptionPresent(). | ||
// then(function (present) { | ||
// nemo.view.myView.cityOption().click(); | ||
// }). | ||
// then(function () { | ||
// driver.sleep(4000); | ||
// }). | ||
// then(function () { | ||
// done(); | ||
// }); | ||
// }); | ||
// it("should use the view and subview methods", function (done) { | ||
// nemo.view.myView.tellLifeStory(). | ||
// then(function () { | ||
// done(); | ||
// }, function (err) { | ||
// //console.log("D'oh'eth"); | ||
// done(err); | ||
// }); | ||
// }); | ||
}); | ||
}); | ||
after(function(done) { | ||
driver.quit().then(function() { | ||
done(); | ||
}); | ||
}); | ||
it("should create a new instance", function(done) { | ||
_nemo.should.not.equal(undefined); | ||
done(); | ||
}); | ||
it("should return back camelcase properties from titlecase ARGV options and also init any plugins", function(done) { | ||
//console.log(_nemo.setup); | ||
var su = _nemo.setup({ | ||
"samplePlugin": { | ||
"sampleoptions": { | ||
"option1": "value1", | ||
"option2": "value2" | ||
} | ||
}, | ||
"locator": ["myView"], | ||
"view": ["myView", "myOtherView"] | ||
}); | ||
//console.log(su) | ||
su.then(function(result) { | ||
nemo = result; | ||
nemo.props.targetBrowser.should.equal("phantomjs"); | ||
//nemo.props.targetServer.should.equal("http://127.0.0.1:4444/wd/hub"); | ||
nemo.props.targetBaseUrl.should.equal("https://www.paypal.com"); | ||
//nemo.noValue.should.equal(true); | ||
nemo.samplePlugin.sampleoptions.option1.should.equal("value1"); | ||
//nemo.autoRegPlugin.should.exist(); | ||
driver = nemo.driver; | ||
done(); | ||
}, function(err) { | ||
done(err); | ||
}); | ||
}); | ||
it("should navigate to the TARGET_BASE_URL set via command line", function(done) { | ||
driver.get(nemo.props.targetBaseUrl). | ||
then(function() { | ||
done(); | ||
}, function(err) { | ||
done(err); | ||
}); | ||
}); | ||
it("should register plugin with priority < 100 prior to driver setup", function() { | ||
nemo.samplePlugin.isDriverSetup.should.equal(false); | ||
return true; | ||
}); | ||
it("should take props values from plugin registration", function() { | ||
nemo.props.fromSamplePlugin.should.equal(true); | ||
return true; | ||
}); | ||
it("should register plugin with no priority after driver setup", function() { | ||
nemo.autoRegPlugin.isDriverSetup.should.equal(true); | ||
return true; | ||
}); | ||
describe("nemo.locator", function() { | ||
it("should have pulled in the myView locator", function(done) { | ||
if (!nemo.locator.myView) { | ||
done(new Error("didn't get the locator")); | ||
} else { | ||
done(); | ||
} | ||
}); | ||
it("should get the FR locator when locale is FR", function(done) { | ||
if (nemo.props.locale === "FR" && nemo.locatex("myView.cityOption").locator === "select[name='ddlTown'] option[value='Burkino Faso']") { | ||
done(); | ||
} else { | ||
done(new Error("didn't get an FR flavored locator")); | ||
} | ||
}); | ||
it("should get the default locator when locale is FR and no FR locator", function(done) { | ||
if (nemo.props.locale === "FR" && nemo.locatex("myView.noFRyesDefault").locator === "defaultId") { | ||
done(); | ||
} else { | ||
done(new Error("didn't get an default flavored locator")); | ||
} | ||
}); | ||
it("should get the single locator when no locale-specific or default locator", function(done) { | ||
if (nemo.props.locale === "FR" && nemo.locatex("myView.noFRnoDefault").locator === "onlyId") { | ||
done(); | ||
} else { | ||
done(new Error("didn't get a non-flavored locator")); | ||
} | ||
}); | ||
}); | ||
describe("nemo.view", function() { | ||
it("should have the view methods available", function(done) { | ||
if (nemo.view.myView && nemo.view.myView.fname && nemo.view.myView.fname.constructor === Function) { | ||
done(); | ||
} else { | ||
done(new Error("didn't get the view method")); | ||
} | ||
}); | ||
it("should use the view methods", function(done) { | ||
nemo.driver.get("https://edit.yahoo.com/registration"); | ||
nemo.view.myView.fnamePresent(). | ||
then(function(present) { | ||
nemo.view.myView.fname().sendKeys("asdf"); | ||
}). | ||
then(function() { | ||
driver.sleep(4000); | ||
}). | ||
then(function() { | ||
done(); | ||
}); | ||
}); | ||
// it("should use the view and subview interface methods", function (done) { | ||
// nemo.driver.get("http://accessify.com/features/tutorials/accessible-forms/form-examples.htm"); | ||
// nemo.view.myView.cityOptionPresent(). | ||
// then(function (present) { | ||
// nemo.view.myView.cityOption().click(); | ||
// }). | ||
// then(function () { | ||
// driver.sleep(4000); | ||
// }). | ||
// then(function () { | ||
// done(); | ||
// }); | ||
// }); | ||
// it("should use the view and subview methods", function (done) { | ||
// nemo.view.myView.tellLifeStory(). | ||
// then(function () { | ||
// done(); | ||
// }, function (err) { | ||
// //console.log("D'oh'eth"); | ||
// done(err); | ||
// }); | ||
// }); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39781
778
193
9