New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nightwatch

Package Overview
Dependencies
Maintainers
1
Versions
360
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nightwatch - npm Package Compare versions

Comparing version 0.4.11 to 0.4.12

lib/keys.json

2

bin/runner.js

@@ -188,2 +188,4 @@ /**

test_settings.output = test_settings.output || typeof test_settings.output === 'undefined';
if (typeof argv.s == 'string') {

@@ -190,0 +192,0 @@ test_settings.skipgroup = argv.s.split(',');

22

examples/tests/google.js

@@ -9,10 +9,2 @@ /**

module.exports = {
setUp : function(c) {
this.client.assert.equal(c.globals.myGlobal, 1, 'checking globals are loaded.');
},
tearDown : function() {
console.log('Closing down...');
},
'demo test google' : function (client) {

@@ -22,13 +14,7 @@ client

.waitForElementPresent('body', 1000)
.setValue('input[type=text]', 'nightwatch', function() {
this
.waitForElementVisible('button[name=btnG]', 1000)
.click('button[name=btnG]', function() {
this
.pause(500)
.assert.containsText('#main', 'The Night Watch');
});
}).end();
.setValue('input[type=text]', ['nightwatch', client.Keys.ENTER])
.pause(1000)
.assert.containsText('#main', 'The Night Watch')
.end();
}
};

@@ -37,4 +37,5 @@ /*!

this.setOptions(options);
this.setCapabilities();
this.setOptions(options)
.setCapabilities()
.loadKeyCodes();

@@ -101,4 +102,2 @@ this.errors = [];

this.options.output = this.options.output || typeof this.options.output === 'undefined';
if (this.options.silent) {

@@ -150,4 +149,10 @@ Logger.disable();

}
return this;
};
Nightwatch.prototype.loadKeyCodes = function() {
this.api.Keys = require('./keys.json');
return this;
};
Nightwatch.prototype.start = function() {

@@ -154,0 +159,0 @@ if (!this.sessionId) {

@@ -92,3 +92,3 @@ var util = require('util');

function logObject(obj) {
util.puts(util.inspect(obj, false, 3, true));
console.log(util.inspect(obj, false, 3, true));
}

@@ -124,3 +124,3 @@

util.print(messageStr);
process.stdout.write(messageStr);

@@ -141,3 +141,3 @@ if (args.length > 0) {

if (inlineArgs.length) {
util.print(' ');
process.stdout.write(' ');
console.log.apply(console, inlineArgs);

@@ -147,3 +147,3 @@ inlineArgs = [];

} else {
util.print('\n');
process.stdout.write('\n');
}

@@ -150,0 +150,0 @@ }

@@ -29,3 +29,3 @@ var util = require('util'),

HttpRequest.prototype.setOptions = function(options) {
this.data = options.data && JSON.stringify(options.data) || '';
this.data = options.data && jsonStringify(options.data) || '';
this.contentLength = this.data.length;

@@ -59,3 +59,3 @@ this.reqOptions = this.createOptions(options);

if (this.contentLength > 0) {
reqOptions.headers['Content-Type'] = 'application/json';
reqOptions.headers['Content-Type'] = 'application/json; charset=utf-8';
}

@@ -119,6 +119,6 @@

if (errorMessage !== '') {
util.puts(Logger.colors.yellow('There was an error while executing the Selenium command') +
console.log(Logger.colors.yellow('There was an error while executing the Selenium command') +
(!Logger.isEnabled() ? ' - enabling the --verbose option might offer more details.' : '')
);
util.puts(errorMessage);
console.log(errorMessage);
}

@@ -152,2 +152,15 @@

/**
*
* @param s
* @param emit_unicode
* @returns {string}
*/
HttpRequest.JSON_stringify = function(s, emit_unicode) {
var json = JSON.stringify(s);
if (json) {
return emit_unicode ? json : json.replace(jsonRegex, jsonRegexReplace);
}
};
HttpRequest.setSeleniumPort = function(port) {

@@ -169,2 +182,24 @@ Settings.selenium_port = port;

///////////////////////////////////////////////////////////
var jsonRegex = new RegExp('[\\u007f-\\uffff]', 'g');
var jsonRegexReplace = function(c) {
return '\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4);
};
/**
* Built in JSON.stringify() will return unicode characters that require UTF-8 encoding on the wire.
* This function will replace unicode characters with their escaped (ASCII-safe) equivalents to support
* the keys sending command.
*
* @param {object} s
* @returns {string}
*/
function jsonStringify(s) {
var json = JSON.stringify(s);
if (json) {
return json.replace(jsonRegex, jsonRegexReplace);
}
return json;
}
function isRedirect(statusCode) {

@@ -171,0 +206,0 @@ return [302, 303, 304].indexOf(statusCode) > -1;

@@ -22,3 +22,3 @@ var fs = require('fs');

* @method click
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {function} [callback] Optional callback function to be called when the command finishes.

@@ -40,3 +40,3 @@ * @see elementIdClick

* @method clearValue
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {function} [callback] Optional callback function to be called when the command finishes.

@@ -62,3 +62,3 @@ * @see elementIdClear

* @method getAttribute
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {string} atttribute The attribute name to inspect.

@@ -86,3 +86,3 @@ * @param {function} [callback] Optional callback function to be called when the command finishes.

* @method getCssProperty
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {string} cssProperty The CSS property to inspect.

@@ -111,3 +111,3 @@ * @param {function} [callback] Optional callback function to be called when the command finishes.

* @method getElementSize
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {function} [callback] Optional callback function to be called when the command finishes.

@@ -137,3 +137,3 @@ * @see elementIdSize

* @method getLocation
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {function} [callback] Optional callback function to be called when the command finishes.

@@ -161,3 +161,3 @@ * @see elementIdLocation

* @method getLocationInView
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {function} [callback] Optional callback function to be called when the command finishes.

@@ -184,3 +184,3 @@ * @see elementIdLocationInView

* @method getTagName
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {function} [callback] Optional callback function to be called when the command finishes.

@@ -207,3 +207,3 @@ * @see elementIdName

* @method getText
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {function} [callback] Optional callback function to be called when the command finishes.

@@ -230,3 +230,3 @@ * @see elementIdText

* @method getValue
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {function} [callback] Optional callback function to be called when the command finishes.

@@ -253,3 +253,3 @@ * @see elementIdValue

* @method isVisible
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {function} [callback] Optional callback function to be called when the command finishes.

@@ -271,3 +271,3 @@ * @see elementIdDisplayed

* @method moveToElement
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {number} xoffset X offset to move to, relative to the top-left corner of the element.

@@ -282,13 +282,22 @@ * @param {number} yoffset Y offset to move to, relative to the top-left corner of the element.

/**
* Sends some text to an element. Can be used to set the value of a form element. Uses `elementIdValue` protocol command.
* Sends some text to an element. Can be used to set the value of a form element or to send a sequence of key strokes to an element. Any UTF-8 character may be specified.
*
* An object map with available keys and their respective UTF-8 characters, as defined on [W3C WebDriver draft spec](http://www.w3.org/TR/webdriver/#character-types), is loaded onto the main Nightwatch instance as `client.Keys`.
*
* ```
* // send some simple text to an input
* this.demoTest = function (browser) {
* browser.setValue('input[type=text]', 'nightwatch');
* };
* //
* // send some text to an input and hit enter.
* this.demoTest = function (browser) {
* browser.setValue('input[type=text]', ['nightwatch', browser.Keys.ENTER]);
* };
* ```
*
* @link /session/:sessionId/element/:id/value
* @method setValue
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} value The text to send to the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {string|array} value The text to send to the element or key strokes.
* @param {function} [callback] Optional callback function to be called when the command finishes.

@@ -310,3 +319,3 @@ * @see elementIdValue

* @method submitForm
* @param {string} cssSelector The CSS selector used to locate the element.
* @param {string} selector The CSS/Xpath selector used to locate the element.
* @param {function} [callback] Optional callback function to be called when the command finishes.

@@ -385,3 +394,6 @@ * @see submit

// alias
returnValue.sendKeys = returnValue.setValue;
return returnValue;
};

@@ -349,3 +349,3 @@ module.exports = function(Nightwatch) {

* @param {string} id ID of the element to route the command to.
* @param {string|none} [value] Value to send to element in case of a POST
* @param {string|array|none} [value] Value to send to element in case of a POST
* @param {function} [callback] Optional callback function to be called when the command finishes.

@@ -360,3 +360,8 @@ * @api protocol

value = String(value);
if (Array.isArray(value)) {
value = value.join('');
} else {
value = String(value);
}
return postRequest('/element/' + id + '/value', {

@@ -778,11 +783,19 @@ value: value.split('')

/**
* Send a sequence of key strokes to the active element.
* Send a sequence of key strokes to the active element. The sequence is defined in the same format as the `sendKeys` command.
* An object map with available keys and their respective UTF-8 characters, as defined on [W3C WebDriver draft spec](http://www.w3.org/TR/webdriver/#character-types), is loaded onto the main Nightwatch instance as `client.Keys`.
*
* Rather than the `setValue`, the modifiers are not released at the end of the call. The state of the modifier keys is kept between calls, so mouse interactions can be performed while modifier keys are depressed.
*
* @link /session/:sessionId/keys
* @param {Array} keys The keys sequence to be sent. The sequence is defined in the send keys format available at: https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/value.
* @param {Array} keysToSend The keys sequence to be sent.
* @param {function} [callback] Optional callback function to be called when the command finishes.
* @api protocol
*/
Actions.keys = function(keys, callback) {
return postRequest('/keys', { value: keys }, callback);
Actions.keys = function(keysToSend, callback) {
if (!Array.isArray(keysToSend)) {
keysToSend = [keysToSend];
}
return postRequest('/keys', {
value: keysToSend
}, callback);
};

@@ -789,0 +802,0 @@

@@ -108,13 +108,16 @@ var exec = require('child_process').exec;

methods[section].push({
name : name,
params : params,
link : link,
api : api,
descr : descr,
example : example,
returns : returns,
since : since,
see : see
});
if (name) {
methods[section].push({
name : name,
params : params,
link : link,
api : api,
descr : descr,
example : example,
returns : returns,
since : since,
see : see
});
}
});

@@ -121,0 +124,0 @@

{
"name": "nightwatch",
"description": "A node.js bindings implementation for selenium 2.0/webdriver",
"version": "0.4.11",
"version": "0.4.12",
"author": {

@@ -6,0 +6,0 @@ "name": "Andrei Rusu",

@@ -857,2 +857,26 @@ module.exports = {

testKeysSingle : function(test) {
var protocol = this.protocol;
this.client.on('selenium:session_create', function() {
var command = protocol.keys('A', function callback() {
test.done();
});
test.equal(command.data, '{"value":["A"]}');
});
},
testKeysUnicode : function(test) {
var protocol = this.protocol;
this.client.on('selenium:session_create', function() {
var command = protocol.keys('\uE007', function callback() {
test.done();
});
test.equal(command.data, '{"value":["\\ue007"]}');
});
},
tearDown : function(callback) {

@@ -859,0 +883,0 @@ this.client = null;

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc