Socket
Socket
Sign inDemoInstall

nemo-view

Package Overview
Dependencies
66
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.3 to 0.2.4

6

index.js

@@ -25,4 +25,4 @@ /*───────────────────────────────────────────────────────────────────────────*\

hang = (hang === undefined) ? true : hang;
if (nemo.view && nemo.view[viewName]) {
return;
if (nemo.view && nemo.view[viewName] && hang === true) {
return nemo.view[viewName];
}

@@ -49,2 +49,2 @@ //error

callback(null, config, nemo);
};
};
{
"name": "nemo-view",
"version": "0.2.3",
"version": "0.2.4",
"description": "View Interface for nemo views (requires nemo-drivex and nemo-locatex plugins)",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -103,3 +103,2 @@ ## nemo-view

nemoFactory = require("nemo-mocha-factory"),
homePage = require("../page/homePage"),
setup = {

@@ -205,5 +204,144 @@ "view": ["selectBox", "textBox"]

```
### Creating nemo plugins with self contained views and flows
You may want to publish complete flows as a nemo plugin. That way you can import the functionality and access as a plugin. The following is an example of that.
```javascript
var path = require("path");
module.exports = {
"setup": function(config, nemo, callback) {
var login = {
'view': {},
'locator': {}
};
var loginLocator = {
"email": {
"locator": "login_email",
"type": "id"
},
"password": {
"locator": "login_password",
"type": "id"
},
"showLogin": {
"locator": "login-button",
"type": "id"
},
"button": {
"locator": "input[type='submit'][name='submit']",
"type": "css"
},
"logoutLink": {
"locator": "li.logout a",
"type": "css"
},
"loggedOutLoginLink": {
"locator": "li.login a",
"type": "css"
}
};
var loginContext = {
'locator': loginLocator,
'name': 'login'
};
login.view.login = nemo.view.addView(loginContext, false);
login.login = function(email, password) {
var me = login.view.login;
nemo.driver.get('https://www.stage2pph20.stage.paypal.com');
me.showLoginVisible().then(function(isVisible) {
if (isVisible) {
return me.showLogin().click();
}
return;
});
me.email().clear();
me.email().sendKeys(email);
me.password().sendKeys(password);
me.button().click();
return me.logoutLinkWait(10000);
};
login.logout = function() {
var me = login.view.login;
me.logoutLink().click();
//nemo.driver.sleep(30000);
return me.loggedOutLoginLink(10000);
};
nemo.login = login;
callback(null, config, nemo);
}
};
```
The above can be registered as a plugin during nemo setup, and accessed as `nemo.login` within a spec.
### Using multiple views in modules external to spec files
You will probably want to share functionality between spec files which encapsulate multiple views (called flow modules). And you may want to use multiple of these flow modules in a single spec. In this case, it makes more sense to allow the flow module to specify which view(s) to include instead of specifying the views at the spec level. Use the nemo-view `addView` method in the flow modules to accomplish this.
Example of the top of a flow file `addCard.js`
```javascript
'use strict';
function addCard(nemo) {
var CC = nemo.view.addView('CC');
var allSet = nemo.view.addView('allSet');
return {
addCC: function(cardNumber, date, csc) {
CC.CCTabLink().click();
```
This module can in turn be included in a spec file as below:
```javascript
'use strict';
var assert = require('assert'),
nemoFactory = require('nemo-mocha-factory'),
nemo = {},
plugins = require('../config/nemo-plugins'),
addCard = require('../flow/addCard'),
addBank = require('../flow/addBank');
describe('@p2@FRbank@migrate@', function() {
nemoFactory({
'plugins': plugins,
'context': nemo
});
before(function(done) {
addCard = addCard(nemo);
addBank = addBank(nemo);
done();
)};
```
Now any of the flow module methods can be used in the spec file, and the correct views will be available in the flow modules.
### View features
#### addView method
The addView method will be added to the nemo.view namespace with the following signature:
`nemo.view.addView(viewSpec, addToNamespace);`
__viewSpec__ {String|JSON} will be either a string, or a JSON object to define the view/locator.
__addToNamespace__ {boolean} (optional, defaults to true) if `false` nemo-view will not attach the view to the `nemo.view` namespace
Using the addView method, you can add a view at any time using the same formats and conventions as if you are adding them in the Nemo.setup() method. Examples:
```javascript
//add using a locator in the autoBaseDir/locator directory
var myPage = nemo.view.addView('myPage');
var login = nemo.view.addView({
"name": "login",
"locator": "path:locator/loggedOut/login"
});
var addCard = nemo.view.addView({
"name": "addCard",
"locator": "module:nemo-paypal-locators/addCard"
});
The addView method will return the view object. It will also dedupe to prevent extra cycles adding the same view multiple times, or overwriting of a view with another of the same name.
```
#### locator methods

@@ -210,0 +348,0 @@ The view will create the following methods for each locator object:

@@ -11,3 +11,3 @@ var should = require('chai').should(),

};
plugins.plugins.yhooreg = {
plugins.plugins.login = {
"module": path.resolve(__dirname, 'plugin/shared-fn-plugin'),

@@ -14,0 +14,0 @@ "register": true

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc