Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nightwatch

Package Overview
Dependencies
Maintainers
1
Versions
355
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.3.3 to 0.3.4

tests/extra/customCommand.js

16

bin/runner.js

@@ -34,7 +34,5 @@ /**

// $ nightwatch -v
// $ nightwatch --verbose
cli.command('verbose')
.description('Turns on selenium command logging during the session.')
.alias('v');
.description('Turns on selenium command logging during the session.');

@@ -65,3 +63,3 @@ // $ nightwatch -t

.alias('f');
// $ nightwatch -s

@@ -73,2 +71,7 @@ // $ nightwatch --skipgroup

// $ nightwatch --version
cli.command('version')
.alias('v')
.description('Shows version information.');
/**

@@ -159,5 +162,8 @@ * Looks for pattern ${VAR_NAME} in settings

var argv = cli.init();
if (argv.help) {
cli.showHelp();
} else if (argv.version) {
var packageConfig = require(__dirname + '/../package.json');
console.log(packageConfig.name + ' v' + packageConfig.version);
} else {

@@ -164,0 +170,0 @@

/**
* Sample automated test scenario for Nightwatch.js
*
*
* > it navigates to google.com and searches for nightwatch,
* verifying if the term 'The Night Watch' exists in the search results
* verifying if the term 'The Night Watch' exists in the search results
*/

@@ -10,9 +10,9 @@

setUp : function(c) {
console.log('Setting up...');
console.log('Setting up...');
},
tearDown : function() {
console.log('Closing down...');
},
'step one' : function (client) {

@@ -24,3 +24,3 @@ client

.url(function(result) {
//this.assert.ok(result.value.indexOf('google.') !== -1, 'Google url is ok');
//this.assert.ok(result.value.indexOf('google.') !== -1, 'Google url is ok');
})

@@ -31,3 +31,3 @@ .assert.visible('input[type=text]')

},
'step two' : function (client) {

@@ -34,0 +34,0 @@ client

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

Logger = require('./logger.js');
function Nightwatch(options) {

@@ -14,3 +14,3 @@ events.EventEmitter.call(this);

this.options = options || {};
var self = this;

@@ -21,3 +21,3 @@ this.sessionId = null;

this.capabilities = {};
this.options.screenshots || (this.options.screenshots = {

@@ -27,7 +27,7 @@ 'enabled' : false,

});
this.options.output = this.options.output || typeof this.options.output == 'undefined';
this.screenshotPath = this.options.screenshotPath || '';
this.launch_url = this.options.launch_url || null;
if (this.options.silent) {

@@ -38,3 +38,3 @@ Logger.disable();

}
if (this.options.selenium_port) {

@@ -52,3 +52,3 @@ HttpRequest.setSeleniumPort(this.options.selenium_port);

username : this.options.username,
key : this.options.access_key
key : this.options.access_key
});

@@ -62,6 +62,6 @@ }

};
if (this.options.desiredCapabilities) {
for (prop in this.options.desiredCapabilities) {
this.desiredCapabilities[prop] = this.options.desiredCapabilities[prop];
for (var prop in this.options.desiredCapabilities) {
this.desiredCapabilities[prop] = this.options.desiredCapabilities[prop];
}

@@ -77,7 +77,7 @@ }

};
this.queue = CommandQueue;
this.queue.empty();
this.queue.reset();
this.loadProtocolActions()

@@ -89,3 +89,3 @@ .loadCommands()

this.loadCustomCommands();
}
}
};

@@ -100,5 +100,5 @@

}
var self = this;
this.queue.reset();

@@ -110,4 +110,4 @@ this.queue.run(function(error) {

self.terminate();
return;
}
return;
}
Logger.info('FINISHED');

@@ -117,3 +117,3 @@ self.emit('queue:finished', self.results, self.errors);

});
return this;
return this;
}

@@ -127,3 +127,3 @@

this.queue.empty();
this.runCommand('session', ['delete'], function(result) {

@@ -133,3 +133,3 @@ self.emit('queue:finished', self.results, self.errors);

});
return this;

@@ -146,3 +146,3 @@ }

}
if (ok && this.results.passed > 0) {

@@ -173,3 +173,3 @@ console.log(Logger.colors.green('OK.'), Logger.colors.green(this.results.passed) + ' assertions passed.');

}
console.log(Logger.colors.red('FAILED: '), failure_msg.join(', ').replace(/,([^,]*)$/g, function($0, $1, index, str) {

@@ -179,8 +179,8 @@ return ' and' +$1;

}
this.errors.length = 0;
this.results.passed = 0;
this.results.failed = 0;
this.results.errors = 0;
this.results.skipped = 0;
this.results.errors = 0;
this.results.skipped = 0;
this.results.tests.length = 0;

@@ -196,3 +196,3 @@ }

});
return this;

@@ -210,3 +210,3 @@ }

var self = this;
commandFiles.forEach(function(file) {

@@ -216,5 +216,11 @@ if (path.extname(file) == '.js') {

var name = path.basename(file, '.js');
self.addCommand(name, command.command, self, self);
if (typeof command === 'function') {
command = new command();
command.client = self;
self.addCommand(name, command.command, command, self);
} else {
self.addCommand(name, command.command, self, self);
}
}
})
});
}

@@ -225,5 +231,5 @@

var assertModule = require('assert');
this.assert = {};
for (var prop in assertModule) {

@@ -235,9 +241,9 @@ if (assertModule.hasOwnProperty(prop)) {

var actual = arguments[0];
var message = typeof arguments[arguments.length-1] == 'string' &&
(arguments.length > 2 || typeof arguments[0] === 'boolean') &&
var message = typeof arguments[arguments.length-1] == 'string' &&
(arguments.length > 2 || typeof arguments[0] === 'boolean') &&
arguments[arguments.length-1]
|| (typeof arguments[0] === 'function' && '[Function]')
|| '' + actual;
try {

@@ -253,3 +259,3 @@ assertModule[prop].apply(null, arguments);

}
return self.assertion(passed, actual, expected, message, true);
return self.assertion(passed, actual, expected, message, true);
}

@@ -259,4 +265,4 @@ })(prop);

}
this.loadAssetionFiles(this.assert, true);
this.loadAssertionFiles(this.assert, true);
}

@@ -266,7 +272,7 @@

this.verify = {};
this.loadAssetionFiles(this.verify, false);
this.loadAssertionFiles(this.verify, false);
return this;
}
Nightwatch.prototype.loadAssetionFiles = function(parent, abortOnFailure) {
Nightwatch.prototype.loadAssertionFiles = function(parent, abortOnFailure) {
var relativePath = './selenium/assertions/';

@@ -278,3 +284,3 @@ var commandFiles = fs.readdirSync(path.join(__dirname, relativePath));

}
for (var i = 0, len = commandFiles.length; i < len; i++) {

@@ -295,8 +301,8 @@ if (path.extname(commandFiles[i]) == '.js') {

this.results.errors++;
var error = new Error('The command "' + name + '" is already defined!');
var error = new Error('The command "' + name + '" is already defined!');
this.errors.push(error.stack)
throw error;
}
var self = this;
parent[name] = (function(internalCommandName) {
var self = this;
parent[name] = (function(internalCommandName) {
return function() {

@@ -308,3 +314,3 @@ var args = Array.prototype.slice.call(arguments);

})(name);
return this;

@@ -314,3 +320,3 @@ };

/**
*
*
* @param {Object} requestOptions

@@ -324,3 +330,3 @@ * @param {Function} callback

if (result.status && result.status !== 0) {
result = self.handleTestError(result);
result = self.handleTestError(result);
}

@@ -334,5 +340,5 @@ request.emit('result', result, response);

var datestamp = d.toLocaleString('en-GB', {
weekday: 'narrow',
year: 'numeric',
month: '2-digit',
weekday: 'narrow',
year: 'numeric',
month: '2-digit',
day: '2-digit',

@@ -348,3 +354,3 @@ timeZoneName : 'short',

}
request.emit('result', result, response);

@@ -356,3 +362,3 @@ })

if (typeof callback != 'function') {
var error = new Error('Callback parameter is not a function - ' + typeof(callback) + ' passed: "' + callback + '"');
var error = new Error('Callback parameter is not a function - ' + typeof(callback) + ' passed: "' + callback + '"');
this.errors.push(error.stack)

@@ -362,3 +368,3 @@ this.results.errors++;

}
callback.call(self, result);
callback.call(self, result);
} catch (ex) {

@@ -375,13 +381,13 @@ console.log(ex.stack)

var self = this;
if (commandName in this) {
args.push(callback);
this[commandName].apply(this, args);
this[commandName].apply(this, args);
} else {
this.results.errors++;
var error = new Error('No such command: ' + commandName);
var error = new Error('No such command: ' + commandName);
this.errors.push(error.stack)
throw error;
}
return this.queue.run();

@@ -392,5 +398,5 @@ }

util.inherits(command, events.EventEmitter);
var instance = new command();
var instance = new command();
events.EventEmitter.call(instance)
return instance;
return instance;
}

@@ -407,7 +413,7 @@

}]);
};
};
Nightwatch.prototype.assertion = function(passed, receivedValue, expectedValue, message, abortOnFailure) {
var failure = '', stacktrace = '';
if (passed) {

@@ -425,3 +431,3 @@ if (this.options.output) {

Error.captureStackTrace(err, arguments.callee);
throw err;
throw err;
} catch (ex) {

@@ -432,5 +438,5 @@ var logged = Logger.colors.red('✖') + ' ' + message;

}
if (this.options.output) {
console.log(logged);
console.log(logged);
}

@@ -441,3 +447,3 @@ stacktrace = ex.stack;

}
this.results.tests.push({

@@ -448,3 +454,3 @@ message : message,

});
if (!passed && abortOnFailure) {

@@ -455,8 +461,8 @@ this.terminate();

};
Nightwatch.prototype.saveScreenshotToFile = function(fileName, content) {
fs.writeFile(fileName, content, 'base64', function(err) {
if (err) {
console.log(Logger.colors.yellow('Couldn\'t save screenshot to '), fileName);
console.log(Logger.colors.yellow('Couldn\'t save screenshot to '), fileName);
Logger.warn(err);

@@ -473,3 +479,3 @@ }

}
var rv = {

@@ -481,3 +487,3 @@ status: -1,

};
return rv;

@@ -495,3 +501,3 @@ };

});
request.on('success', function(data, response) {

@@ -514,7 +520,6 @@ if (data.sessionId) {

.send();
return this;
return this;
};
var instance = null;
exports.client = function(options) {

@@ -521,0 +526,0 @@ return new Nightwatch(options);

var Actions = {},
MOUSE_BUTTON_LEFT = "left",
MOUSE_BUTTON_MIDDLE = "middle",
MOUSE_BUTTON_RIGHT = "right",
DIRECTION_UP = "up",
DIRECTION_DOWN = "down";
MOUSE_BUTTON_LEFT = 'left',
MOUSE_BUTTON_MIDDLE = 'middle',
MOUSE_BUTTON_RIGHT = 'right',
DIRECTION_UP = 'up',
DIRECTION_DOWN = 'down';
Actions.element = function(using, value, callback) {
var check = /class name|css selector|id|name|link text|partial link text|tag name|xpath/gi;
if (!check.test(using)) {
throw new Error("Please provide any of the following using strings as the first parameter: " +
"class name, css selector, id, name, link text, partial link text, tag name or xpath");
throw new Error('Please provide any of the following using strings as the first parameter: ' +
'class name, css selector, id, name, link text, partial link text, tag name or xpath');
}
return postRequest.call(this, "/element", {
"using": using,
"value": value
return postRequest.call(this, '/element', {
'using': using,
'value': value
}, callback);

@@ -22,12 +22,12 @@ };

Actions.elementActive = function(callback) {
return postRequest.call(this, "/element/active", {}, callback);
return postRequest.call(this, '/element/active', {}, callback);
};
Actions.elementIdAttribute = function(id, attributeName, callback) {
return getRequest.call(this,
"/element/" + id + "/attribute/" + attributeName, callback);
return getRequest.call(this,
'/element/' + id + '/attribute/' + attributeName, callback);
};
Actions.elementIdClick = function(id, callback) {
return postRequest.call(this, "/element/" + id + "/click", '', callback);
return postRequest.call(this, '/element/' + id + '/click', '', callback);
};

@@ -42,5 +42,5 @@

* used for implementing drag-and-drop.
*
* The button can be (0, 1, 2) or ('left', 'middle', 'right'). It defaults to
* left mouse button, and if you don't pass in a button but do pass in a callback,
*
* The button can be (0, 1, 2) or ('left', 'middle', 'right'). It defaults to
* left mouse button, and if you don't pass in a button but do pass in a callback,
* it will handle it correctly.

@@ -58,14 +58,14 @@ */

var buttonIndex;
if (typeof(button) == "function") {
if (typeof(button) === 'function') {
callback = button;
button = 0;
}
if (typeof button == "string") {
if (typeof button === 'string') {
buttonIndex = [
MOUSE_BUTTON_LEFT,
MOUSE_BUTTON_MIDDLE,
MOUSE_BUTTON_LEFT,
MOUSE_BUTTON_MIDDLE,
MOUSE_BUTTON_RIGHT
].indexOf(button.toLowerCase());
if (buttonIndex !== -1) {

@@ -75,19 +75,19 @@ button = buttonIndex;

}
return postRequest.call(that, "/button" + direction, {button: button}, callback);
};
return postRequest.call(that, '/button' + direction, {button: button}, callback);
}
/**
* http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/element/:id/css/:propertyName
*
* Query the value of an element's computed CSS property. The CSS property to query should be specified using
*
* Query the value of an element's computed CSS property. The CSS property to query should be specified using
* the CSS property name, not the JavaScript property name (e.g. background-color instead of backgroundColor).
*
*
* @param {String} id - ID of the element to route the command to (ID is a WebElement JSON object)
* @param {String} cssProperyName
* @param {Function} callback
*/
*/
Actions.elementIdCssProperty = function(id, cssProperyName, callback) {
return getRequest.call(this,
"/element/" + id + "/css/" + cssProperyName,
return getRequest.call(this,
'/element/' + id + '/css/' + cssProperyName,
callback);

@@ -101,4 +101,4 @@ };

Actions.elementIdDisplayed = function(id, callback) {
return getRequest.call(this,
"/element/" + id + "/displayed",
return getRequest.call(this,
'/element/' + id + '/displayed',
callback);

@@ -112,4 +112,4 @@ };

Actions.elementIdLocationInView = function(id, callback) {
return getRequest.call(this,
"/element/" + id + "/location_in_view",
return getRequest.call(this,
'/element/' + id + '/location_in_view',
callback);

@@ -119,12 +119,12 @@ };

/**
* Determine an element's location on the page. The point (0, 0) refers to the upper-left corner of the page.
* Determine an element's location on the page. The point (0, 0) refers to the upper-left corner of the page.
* The element's coordinates are returned as a JSON object with x and y properties.
*
*
* Returns {x:number, y:number} The X and Y coordinates for the element on the page.
*
*
* @param {String} id - ID of the element to route the command to (ID is a WebElement JSON object)
* @param {Function} callback
* @param {Function} callback
*/
Actions.elementIdLocation = function(id, callback) {
return getRequest.call(this, "/element/" + id + "/location", callback);
return getRequest.call(this, '/element/' + id + '/location', callback);
};

@@ -138,4 +138,4 @@

Actions.elementIdName = function(id, callback) {
return getRequest.call(this,
"/element/" + id + "/name", callback);
return getRequest.call(this,
'/element/' + id + '/name', callback);
};

@@ -148,20 +148,20 @@

Actions.elementIdClear = function(id, callback) {
return postRequest.call(this, "/element/" + id + "/clear", callback);
return postRequest.call(this, '/element/' + id + '/clear', callback);
};
Actions.elementIdSelected = function(id, callback) {
return getRequest.call(this, "/element/" + id + "/selected", callback);
return getRequest.call(this, '/element/' + id + '/selected', callback);
};
Actions.elementIdEnabled = function(id, callback) {
return getRequest.call(this, "/element/" + id + "/enabled", callback);
return getRequest.call(this, '/element/' + id + '/enabled', callback);
};
Actions.elementIdEquals = function(id1, id2, callback) {
return getRequest.call(this, "/element/" + id1 + "/equals/" + id2, callback);
return getRequest.call(this, '/element/' + id1 + '/equals/' + id2, callback);
};
Actions.elementIdSize = function(id, callback) {
return getRequest.call(this,
"/element/" + id + "/size",
return getRequest.call(this,
'/element/' + id + '/size',
callback);

@@ -171,4 +171,4 @@ };

Actions.elementIdText = function(id, callback) {
return getRequest.call(this,
"/element/" + id + "/text",
return getRequest.call(this,
'/element/' + id + '/text',
callback);

@@ -180,10 +180,10 @@ };

callback = value;
return getRequest.call(this,
"/element/" + id + "/value",
callback);
return getRequest.call(this,
'/element/' + id + '/value',
callback);
}
value = String(value);
return postRequest.call(this, "/element/" + id + "/value", {
"value": value.split("")
return postRequest.call(this, '/element/' + id + '/value', {
'value': value.split('')
}, callback);

@@ -193,7 +193,7 @@ };

/**
* Search for an element on the page, starting from the document root. The located element will be
* returned as a WebElement JSON object.
* The table below lists the locator strategies that each server should support. Each locator must
* Search for an element on the page, starting from the document root. The located element will be
* returned as a WebElement JSON object.
* The table below lists the locator strategies that each server should support. Each locator must
* return the first matching element located in the DOM.
*
*
* class name Returns an element whose class name contains the search value; compound class names are not permitted.

@@ -207,4 +207,4 @@ * css selector Returns an element matching a CSS selector.

* xpath Returns an element matching an XPath expression.
*
* @param {Object} using
*
* @param {String} using
* @param {Object} value

@@ -216,25 +216,46 @@ * @param {Object} callback

if (!check.test(using)) {
throw new Error("Please provide any of the following using strings as the first parameter: " +
"class name, css selector, id, name, link text, partial link text, tag name or xpath");
throw new Error('Please provide any of the following using strings as the first parameter: ' +
'class name, css selector, id, name, link text, partial link text, tag name or xpath');
}
return postRequest.call(this, "/elements", {
"using": using,
"value": value
return postRequest.call(this, '/elements', {
'using': using,
'value': value
}, callback);
};
function executeHandler(path, script, args, callback) {
var fn;
if (typeof script === 'function') {
fn = 'var passedArgs = Array.prototype.slice.call(arguments,0); return ' +
script.toString().replace(/\n+/g, '') + '.apply(window, passedArgs);';
} else {
fn = script;
}
if ((arguments.length === 3) && (typeof arguments[2] === 'function')) {
callback = arguments[2];
args = [];
}
return postRequest.call(this, path, {
'script': fn,
'args': args
}, callback);
}
/**
* Inject a snippet of JavaScript into the page for execution in the context of the currently selected
* frame. The executed script is assumed to be synchronous and the result of evaluating the script is
* Inject a snippet of JavaScript into the page for execution in the context of the currently selected
* frame. The executed script is assumed to be synchronous and the result of evaluating the script is
* returned to the client.
*
* The script argument defines the script to execute in the form of a function body. The value
* returned by that function will be returned to the client. The function will be invoked with the
*
* The script argument defines the script to execute in the form of a function body. The value
* returned by that function will be returned to the client. The function will be invoked with the
* provided args array and the values may be accessed via the arguments object in the order specified.
*
* Arguments may be any JSON-primitive, array, or JSON object. JSON objects that define a WebElement
* reference will be converted to the corresponding DOM element. Likewise, any WebElements in the
*
* Arguments may be any JSON-primitive, array, or JSON object. JSON objects that define a WebElement
* reference will be converted to the corresponding DOM element. Likewise, any WebElements in the
* script result will be returned to the client as WebElement JSON objects.
*
*
* Potential Errors:

@@ -244,29 +265,51 @@ * - NoSuchWindow - If the currently selected window has been closed.

* - JavaScriptError - If the script throws an Error.
*
* @param {String} string
*
* @param {String} script
* @param {Array} args
* @param {Function} callback
* @param {Function} callback
*/
Actions.execute = function(script, args, callback) {
if (typeof script == 'function') {
var fn = 'var passedArgs = Array.prototype.slice.call(arguments,0); return ' + script.toString() + '.apply(window, passedArgs);';
} else {
fn = script;
}
if (arguments.length == 2 && typeof arguments[1] == 'function') {
callback = arguments[1];
args = [];
}
return postRequest.call(this, "/execute", {
"script": fn,
"args": args
}, callback);
}
var args = Array.prototype.slice.call(arguments, 0);
args.unshift('/execute');
return executeHandler.apply(this, args);
};
/**
* Change focus to another frame on the page. If the frame id is null, the server
* Inject a snippet of JavaScript into the page for execution in the context of the currently selected
* frame. The executed script is assumed to be asynchronous and the result of evaluating the script is
* returned to the client.
*
* Asynchronous script commands may not span page loads. If an unload event is fired while waiting for
* a script result, an error should be returned to the client.
*
* The script argument defines the script to execute in the form of a function body. The value
* returned by that function will be returned to the client. The function will be invoked with the
* provided args array and the values may be accessed via the arguments object in the order specified.
*
* Arguments may be any JSON-primitive, array, or JSON object. JSON objects that define a WebElement
* reference will be converted to the corresponding DOM element. Likewise, any WebElements in the
* script result will be returned to the client as WebElement JSON objects.
*
* Potential Errors:
* - NoSuchWindow - If the currently selected window has been closed.
* - StaleElementReference - If one of the script arguments is a WebElement that is not attached to the page's DOM.
* - Timeout - If the script callback is not invoked before the timout expires.
* - JavaScriptError - If the script throws an Error.
*
* @param {String} script
* @param {Array} args
* @param {Function} callback
*/
Actions.execute_async = function(script, args, callback) {
var args = Array.prototype.slice.call(arguments, 0);
args.unshift('/execute_async');
return executeHandler.apply(this, args);
};
/**
* Change focus to another frame on the page. If the frame id is null, the server
* should switch to the page's default content.
*
*
* @param {String} frameId

@@ -276,9 +319,9 @@ * @param {Function} callback

Actions.frame = function(frameId, callback) {
if (arguments.length == 1 && typeof frameId == "function") {
if (arguments.length === 1 && typeof frameId === 'function') {
callback = frameId;
return postRequest.call(this, "/frame", callback);
return postRequest.call(this, '/frame', callback);
}
return postRequest.call(this, "/frame", {
"id": frameId
return postRequest.call(this, '/frame', {
'id': frameId
}, callback);

@@ -288,11 +331,11 @@ };

/**
* Move the mouse by an offset of the specificed element. If no element is specified, the move is relative
* to the current mouse cursor. If an element is provided but no offset, the mouse will be moved to the
* Move the mouse by an offset of the specificed element. If no element is specified, the move is relative
* to the current mouse cursor. If an element is provided but no offset, the mouse will be moved to the
* center of the element. If the element is not visible, it will be scrolled into view.
*
* @param {String} element - Opaque ID assigned to the element to move to. If not specified or is null,
*
* @param {String} element - Opaque ID assigned to the element to move to. If not specified or is null,
* the offset is relative to current position of the mouse.
* @param {Number} xoffset - X offset to move to, relative to the top-left corner of the element.
* @param {Number} xoffset - X offset to move to, relative to the top-left corner of the element.
* If not specified, the mouse will move to the middle of the element.
* @param {String} yoffset - Y offset to move to, relative to the top-left corner of the element.
* @param {String} yoffset - Y offset to move to, relative to the top-left corner of the element.
* If not specified, the mouse will move to the middle of the element.

@@ -302,3 +345,3 @@ * @param {Function} callback

Actions.moveTo = function(element, xoffset, yoffset, callback) {
var data = {}
var data = {};
if (typeof element == 'string') {

@@ -313,13 +356,13 @@ data.element = element;

}
return postRequest.call(this,
"/moveto", data, callback);
return postRequest.call(this,
'/moveto', data, callback);
};
Actions.submit = function(id, callback) {
return postRequest.call(this,
"/element/" + id + "/submit", "", callback);
return postRequest.call(this,
'/element/' + id + '/submit', '', callback);
};
Actions.screenshot = function(callback) {
return getRequest.call(this, "/screenshot", callback);
return getRequest.call(this, '/screenshot', callback);
};

@@ -331,7 +374,7 @@

Actions.status = function(callback) {
return getRequest.call(this, "/status", callback);
return getRequest.call(this, '/status', callback);
};
Actions.title = function(callback) {
return getRequest.call(this, "/title", callback);
return getRequest.call(this, '/title', callback);
};

@@ -342,5 +385,11 @@

/////////////////////////////////////////////////////////////////////////////
/**
*
* @param {String} method
* @returns {*}
*/
Actions.window = function(method) {
method = method.toUpperCase();
var callback;
switch (method) {

@@ -352,3 +401,3 @@ case 'POST':

var handleOrName = arguments[1];
var callback = arguments[2] || function() {};
callback = arguments[2] || function() {};

@@ -358,21 +407,21 @@ return postRequest.call(this, '/window', {

}, callback);
case 'DELETE':
var options = {
path : '/session/' + this.sessionId + '/window',
method : "DELETE"
}
var callback = arguments[1] || function() {};
method : 'DELETE'
};
callback = arguments[1] || function() {};
return this.runProtocolCommand(options, callback).send();
default:
throw new Error('This method expects first argument to be either POST or DELETE.');
}
throw new Error('This method expects first argument to be either POST or DELETE.');
}
};
Actions.window_handle = function(callback) {
return getRequest.call(this, "/window_handle", callback);
return getRequest.call(this, '/window_handle', callback);
};
Actions.window_handles = function(callback) {
return getRequest.call(this, "/window_handles", callback);
return getRequest.call(this, '/window_handles', callback);
};

@@ -383,8 +432,8 @@

* is a function it will be used as a callback and the call will perform
* a get request to retrieve the existing window size.
*
* a get request to retrieve the existing window size.
*
* @param {String} windowHandle
* @param {Number} width
* @param {Number} height
* @param {Function} height
* @param {Function} callback
*/

@@ -395,27 +444,27 @@ Actions.windowSize = function(windowHandle, width, height, callback) {

}
var path = '/window/' + windowHandle + '/size';
var path = '/window/' + windowHandle + '/size';
if (arguments.length == 2 && typeof arguments[1] == 'function') {
return getRequest.call(this, path, arguments[1]);
}
width = Number(width);
height = Number(height);
if (typeof width !== 'number' || isNaN(width)) {
throw new Error('Width and height arguments must be passed as numbers.');
}
if (typeof height !== 'number' || isNaN(height)) {
throw new Error('Width and height arguments must be passed as numbers.');
}
return postRequest.call(this, path, {
width : width,
height : height
}, callback);
}, callback);
};
Actions.refresh = function(callback) {
return postRequest.call(this, "/refresh", callback);
return postRequest.call(this, '/refresh', callback);
};

@@ -427,20 +476,20 @@

/**
* Accepts the currently displayed alert dialog. Usually, this is equivalent
* Accepts the currently displayed alert dialog. Usually, this is equivalent
* to clicking on the 'OK' button in the dialog.
*
*
* @param {Function} callback
*/
Actions.accept_alert = function(callback) {
return postRequest.call(this, "/accept_alert", callback);
return postRequest.call(this, '/accept_alert', callback);
};
/**
* Dismisses the currently displayed alert dialog. For confirm() and prompt()
* dialogs, this is equivalent to clicking the 'Cancel' button. For alert()
* Dismisses the currently displayed alert dialog. For confirm() and prompt()
* dialogs, this is equivalent to clicking the 'Cancel' button. For alert()
* dialogs, this is equivalent to clicking the 'OK' button.
*
*
* @param {Function} callback
*/
Actions.dismiss_alert = function(callback) {
return postRequest.call(this, "/dismiss_alert", callback);
return postRequest.call(this, '/dismiss_alert', callback);
};

@@ -451,6 +500,6 @@

* POST /session/:sessionId/url - Navigate to a new URL.
*
*
* Potential Errors:
* NoSuchWindow - If the currently selected window has been closed.
*
*
* @param {String} url

@@ -460,13 +509,13 @@ * @param {Function} callback

Actions.url = function(url, callback) {
if (typeof url == "string") {
return postRequest.call(this, "/url", {
if (typeof url == 'string') {
return postRequest.call(this, '/url', {
url : url
}, callback);
}
if (typeof url == "function") {
}
if (typeof url == 'function') {
callback = url;
}
return getRequest.call(this, "/url", callback);
return getRequest.call(this, '/url', callback);
};

@@ -476,20 +525,20 @@

var options = {
path : "/session"
path : '/session'
};
if (typeof action == "function") {
if (typeof action === 'function') {
callback = action;
action = "get";
action = 'get';
}
switch (action) {
case "delete":
case 'delete':
options.path += '/' + this.sessionId;
options.method = "DELETE";
options.method = 'DELETE';
break;
default:
options.method = "GET";
}
return this.runProtocolCommand(options, callback).send();
options.method = 'GET';
}
return this.runProtocolCommand(options, callback).send();
};

@@ -502,7 +551,7 @@

var options = {
path : "/session/" + this.sessionId + path,
method : "GET"
}
path : '/session/' + this.sessionId + path,
method : 'GET'
};
callback = callback || function() {};
return this.runProtocolCommand(options, callback).send();

@@ -512,12 +561,12 @@ }

function postRequest(path, data, callback) {
if (arguments.length == 2 && typeof data == "function") {
if (arguments.length === 2 && typeof data === 'function') {
callback = data;
data = "";
data = '';
}
var options = {
path : "/session/" + this.sessionId + path,
method : "POST",
data : data || ""
}
path : '/session/' + this.sessionId + path,
method : 'POST',
data : data || ''
};
callback = callback || function() {};

@@ -524,0 +573,0 @@ return this.runProtocolCommand(options, callback).send();

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

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

# Nightwatch
[![Build Status](https://travis-ci.org/beatfactor/nightwatch.png?branch=master)](https://travis-ci.org/beatfactor/nightwatch) [![NPM version](https://badge.fury.io/js/nightwatch.png)](http://badge.fury.io/js/nightwatch)
UI automated testing framework powered by [Node.js](http://nodejs.org/). It uses the [Selenium WebDriver API](https://code.google.com/p/selenium/wiki/JsonWireProtocol).
UI automated testing framework based on [Node.js](http://nodejs.org/) and [Selenium WebDriver](http://docs.seleniumhq.org/projects/webdriver/)
[![Build Status](https://travis-ci.org/beatfactor/nightwatch.png?branch=master)](https://travis-ci.org/beatfactor/nightwatch) [![NPM version](https://badge.fury.io/js/nightwatch.png)](http://badge.fury.io/js/nightwatch) [![Dependency Status](https://david-dm.org/beatfactor/nightwatch.png)](https://david-dm.org/beatfactor/nightwatch)

@@ -25,5 +25,3 @@ ***

### Run tests
The tests for nightwatch are written using [nodeunit](https://github.com/caolan/nodeunit) as the test framework.
To run the nodeunit tests do:
The tests for nightwatch are written using [nodeunit](https://github.com/caolan/nodeunit) as the test framework. To run the nodeunit tests do:
```sh

@@ -34,2 +32,2 @@ $ npm test

### Discuss
In addition to [Twitter](https://twitter.com/nightwatchjs), a newly setup [Mailing List](https://groups.google.com/forum/#!forum/nightwatchjs) is also available for Nightwatch related discussions.
In addition to [Twitter](https://twitter.com/nightwatchjs), the [Mailing List/Google Group](https://groups.google.com/forum/#!forum/nightwatchjs) is also available for Nightwatch related discussions.

@@ -6,6 +6,6 @@ module.exports = {

},
"Test initialization" : function(test) {
var self = this;
this.client.on('selenium:session_create', function(sessionId) {

@@ -16,3 +16,3 @@ test.equal(self.client.sessionId, 1352110219202, "Testing if session ID was set correctly");

},
testAddCommand : function(test) {

@@ -22,19 +22,45 @@ this.client.on('selenium:session_create', function(sessionId) {

});
var command = function() {
return "testCommand action";
return "testCommand action";
};
this.client.addCommand('testCommand', command, this.client);
test.ok("testCommand" in this.client, "Test if the command was added");
test.ok('testCommand' in this.client, 'Test if the command was added');
try {
this.client.addCommand('testCommand', command, this.client);
this.client.addCommand('testCommand', command, this.client);
} catch (ex) {
var err = ex;
}
test.ok(err instanceof Error);
},
testAddCustomCommand : function(test) {
var client = this.client;
client.on('selenium:session_create', function(sessionId) {
test.done();
});
var commandsTemp = {};
var addCommandFn = client.addCommand;
client.addCommand = function(name, commandFn, context, parent) {
commandsTemp[name] = {
fn : commandFn,
context : context,
parent : parent
};
};
client.options.custom_commands_path = './extra';
client.loadCustomCommands();
test.ok('customCommand' in commandsTemp, 'Test if the custom command was added');
test.ok('customCommandConstructor' in commandsTemp, 'Test if the custom command was added');
var command = commandsTemp.customCommandConstructor;
test.equal(command.context.client, client, 'Command should contain a reference to main client instance.');
},
'Test runProtocolCommand without error' : function(test) {

@@ -48,8 +74,8 @@ var client = this.client;

});
test.ok("send" in request);
request.on('result', function(result, response) {
test.equal(result.status, 0);
test.done();
test.done();
}).on('complete', function() {

@@ -60,9 +86,9 @@ }).on('error', function() {

},
'Test runProtocolCommand with error' : function(test) {
var client = this.client;
this.client.saveScreenshotToFile = function() {};
this.client.options.screenshots.enabled = true;
this.client.on('selenium:session_create', function(sessionId) {

@@ -74,3 +100,3 @@ var request = client.runProtocolCommand({

});
request.on('result', function(result) {

@@ -86,3 +112,3 @@ test.equal(result.status, -1);

},
testRunCommand : function(test) {

@@ -95,3 +121,3 @@ var client = this.client;

},
tearDown : function(callback) {

@@ -104,2 +130,2 @@ this.client.queue.reset();

}

@@ -8,6 +8,6 @@ var protocol = require('../../lib/selenium/protocol.js');

},
testElement : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -17,3 +17,3 @@ var command = protocol.actions.element.call(client, 'id', '#weblogin', function callback() {

});
test.equal(command.request.method, 'POST');

@@ -24,6 +24,6 @@ test.equal(command.data, '{"using":"id","value":"#weblogin"}');

},
testElementPlural : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -33,3 +33,3 @@ var command = protocol.actions.elements.call(client, 'id', '#weblogin', function callback() {

});
test.equal(command.request.method, 'POST');

@@ -40,6 +40,6 @@ test.equal(command.data, '{"using":"id","value":"#weblogin"}');

},
testElementActive : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -49,3 +49,3 @@ var command = protocol.actions.elementActive.call(client, function callback() {

});
test.equal(command.request.method, 'POST');

@@ -56,6 +56,6 @@ test.equal(command.data, '{}');

},
testElementIdClear : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -65,3 +65,3 @@ var command = protocol.actions.elementIdClear.call(client, 'TEST_ELEMENT', function callback() {

});
test.equal(command.request.method, 'POST');

@@ -72,6 +72,6 @@ test.equal(command.data, '');

},
testElementIdSelected : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -81,3 +81,3 @@ var command = protocol.actions.elementIdSelected.call(client, 'TEST_ELEMENT', function callback() {

});
test.equal(command.request.method, 'GET');

@@ -87,6 +87,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/TEST_ELEMENT/selected');

},
testElementIdEnabled : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -96,3 +96,3 @@ var command = protocol.actions.elementIdEnabled.call(client, 'TEST_ELEMENT', function callback() {

});
test.equal(command.request.method, 'GET');

@@ -102,6 +102,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/TEST_ELEMENT/enabled');

},
testElementIdEquals : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -111,3 +111,3 @@ var command = protocol.actions.elementIdEquals.call(client, 'ELEMENT1', 'ELEMENT2', function callback() {

});
test.equal(command.request.method, 'GET');

@@ -117,6 +117,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/ELEMENT1/equals/ELEMENT2');

},
testElementIdAttribute : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -126,3 +126,3 @@ var command = protocol.actions.elementIdAttribute.call(client, 'TEST_ELEMENT', 'test_attr', function callback() {

});
test.equal(command.request.method, 'GET');

@@ -132,6 +132,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/TEST_ELEMENT/attribute/test_attr');

},
testElementIdClick : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -141,3 +141,3 @@ var command = protocol.actions.elementIdClick.call(client, 'TEST_ELEMENT', function callback() {

});
test.equal(command.request.method, 'POST');

@@ -147,6 +147,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/TEST_ELEMENT/click');

},
testElementIdCssProperty : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -156,3 +156,3 @@ var command = protocol.actions.elementIdCssProperty.call(client, 'TEST_ELEMENT', 'test_property', function callback() {

});
test.equal(command.request.method, 'GET');

@@ -162,6 +162,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/TEST_ELEMENT/css/test_property');

},
testElementIdDisplayed : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -171,3 +171,3 @@ var command = protocol.actions.elementIdDisplayed.call(client, 'TEST_ELEMENT', function callback() {

});
test.equal(command.request.method, 'GET');

@@ -177,6 +177,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/TEST_ELEMENT/displayed');

},
testElementIdLocation : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -186,3 +186,3 @@ var command = protocol.actions.elementIdLocation.call(client, 'TEST_ELEMENT', function callback() {

});
test.equal(command.request.method, 'GET');

@@ -192,6 +192,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/TEST_ELEMENT/location');

},
testElementIdLocationInView : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -201,3 +201,3 @@ var command = protocol.actions.elementIdLocationInView.call(client, 'TEST_ELEMENT', function callback() {

});
test.equal(command.request.method, 'GET');

@@ -207,6 +207,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/TEST_ELEMENT/location_in_view');

},
testElementIdName : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -216,3 +216,3 @@ var command = protocol.actions.elementIdName.call(client, 'TEST_ELEMENT', function callback() {

});
test.equal(command.request.method, 'GET');

@@ -222,6 +222,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/TEST_ELEMENT/name');

},
testElementIdSize : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -231,3 +231,3 @@ var command = protocol.actions.elementIdSize.call(client, 'TEST_ELEMENT', function callback() {

});
test.equal(command.request.method, 'GET');

@@ -237,6 +237,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/TEST_ELEMENT/size');

},
testElementIdText : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -246,3 +246,3 @@ var command = protocol.actions.elementIdText.call(client, 'TEST_ELEMENT', function callback() {

});
test.equal(command.request.method, 'GET');

@@ -252,6 +252,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/TEST_ELEMENT/text');

},
testElementIdValueGet : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -261,3 +261,3 @@ var command = protocol.actions.elementIdValue.call(client, 'TEST_ELEMENT', function callback() {

});
test.equal(command.request.method, 'GET');

@@ -267,6 +267,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/element/TEST_ELEMENT/value');

},
testElementIdValuePost : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -276,3 +276,3 @@ var command = protocol.actions.elementIdValue.call(client, 'TEST_ELEMENT', 'test', function callback() {

});
test.equal(command.request.method, 'POST');

@@ -283,6 +283,6 @@ test.equal(command.data, '{"value":["t","e","s","t"]}');

},
testExecute : function(test) {
testExecuteString : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -292,3 +292,3 @@ var command = protocol.actions.execute.call(client, '<script>test();</script>', ['arg1'], function callback() {

});
test.equal(command.request.method, 'POST');

@@ -299,6 +299,48 @@ test.equal(command.data, '{"script":"<script>test();</script>","args":["arg1"]}');

},
testExecuteFunction : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {
var command = protocol.actions.execute.call(client, function() {return test();},
['arg1'], function callback() {
test.done();
});
test.equal(command.data, '{"script":"var passedArgs = Array.prototype.slice.call(arguments,0); ' +
'return function () {return test();}.apply(window, passedArgs);","args":["arg1"]}');
});
},
testExecuteAsync : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {
var command = protocol.actions.execute_async.call(client, '<script>test();</script>', ['arg1'], function callback() {
test.done();
});
test.equal(command.request.method, 'POST');
test.equal(command.data, '{"script":"<script>test();</script>","args":["arg1"]}');
test.equal(command.request.path, '/wd/hub/session/1352110219202/execute_async');
});
},
testExecuteAsyncFunction : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {
var command = protocol.actions.execute_async.call(client, function() {return test();},
['arg1'], function callback() {
test.done();
});
test.equal(command.data, '{"script":"var passedArgs = Array.prototype.slice.call(arguments,0); ' +
'return function () {return test();}.apply(window, passedArgs);","args":["arg1"]}');
});
},
testFrameDefault : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -308,3 +350,3 @@ var command = protocol.actions.frame.call(client, function callback() {

});
test.equal(command.request.method, 'POST');

@@ -314,6 +356,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/frame');

},
testFramePost : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -323,3 +365,3 @@ var command = protocol.actions.frame.call(client, 'testFrame', function callback() {

});
test.equal(command.request.method, 'POST');

@@ -330,6 +372,6 @@ test.equal(command.data, '{"id":"testFrame"}');

},
"test mouseButtonDown click left" : function(test) {
'test mouseButtonDown click left' : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -339,3 +381,3 @@ var command = protocol.actions.mouseButtonDown.call(client, 'left', function callback() {

});
test.equal(command.request.method, 'POST');

@@ -346,6 +388,6 @@ test.equal(command.data, '{"button":0}');

},
"test mouseButtonDown click middle" : function(test) {
'test mouseButtonDown click middle' : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -355,10 +397,10 @@ var command = protocol.actions.mouseButtonDown.call(client, 'middle', function callback() {

});
test.equal(command.data, '{"button":1}');
});
},
"test mouseButtonDown with callback only" : function(test) {
'test mouseButtonDown with callback only' : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -368,10 +410,10 @@ var command = protocol.actions.mouseButtonDown.call(client, function callback() {

});
test.equal(command.data, '{"button":0}');
});
},
"test mouseButtonUp click right" : function(test) {
'test mouseButtonUp click right' : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -381,3 +423,3 @@ var command = protocol.actions.mouseButtonUp.call(client, 'right', function callback() {

});
test.equal(command.request.method, 'POST');

@@ -388,6 +430,6 @@ test.equal(command.data, '{"button":2}');

},
testMoveTo : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -397,3 +439,3 @@ var command = protocol.actions.moveTo.call(client, 'testElement', 0, 1, function callback() {

});
test.equal(command.request.method, 'POST');

@@ -407,3 +449,3 @@ test.equal(command.data, '{"element":"testElement","xoffset":0,"yoffset":1}');

var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -413,3 +455,3 @@ var command = protocol.actions.refresh.call(client, function callback() {

});
test.equal(command.request.method, 'POST');

@@ -422,3 +464,3 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/refresh');

var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -428,3 +470,3 @@ var command = protocol.actions.doubleClick.call(client, function callback() {

});
test.equal(command.request.method, "POST");

@@ -434,6 +476,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/doubleclick');

},
testScreenshot : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -443,3 +485,3 @@ var command = protocol.actions.screenshot.call(client, function callback() {

});
test.equal(command.request.method, 'GET');

@@ -449,6 +491,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/screenshot');

},
testStatus : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -458,3 +500,3 @@ var command = protocol.actions.status.call(client, function callback() {

});
test.equal(command.request.method, 'GET');

@@ -464,6 +506,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/status');

},
testSubmit : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -473,3 +515,3 @@ var command = protocol.actions.submit.call(client, 'TEST_ELEMENT', function callback() {

});
test.equal(command.request.method, 'POST');

@@ -480,6 +522,6 @@ test.equal(command.data, '');

},
testTitle : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -489,3 +531,3 @@ var command = protocol.actions.title.call(client, function callback() {

});
test.equal(command.request.method, 'GET');

@@ -495,6 +537,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/title');

},
testWindowHandle : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -504,3 +546,3 @@ var command = protocol.actions.window_handle.call(client, function callback() {

});
test.equal(command.request.method, 'GET');

@@ -510,6 +552,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/window_handle');

},
testWindowHandlePlural : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -519,3 +561,3 @@ var command = protocol.actions.window_handles.call(client, function callback() {

});
test.equal(command.request.method, 'GET');

@@ -525,6 +567,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/window_handles');

},
testCloseWindow : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -534,3 +576,3 @@ var command = protocol.actions.window.call(client, 'DELETE', function callback() {

});
test.equal(command.request.method, 'DELETE');

@@ -540,6 +582,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/window');

},
testSwitchWindow : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -549,3 +591,3 @@ var command = protocol.actions.window.call(client, 'POST', 'other-window', function callback() {

});
test.equal(command.request.method, 'POST');

@@ -556,3 +598,3 @@ test.equal(command.data, '{"name":"other-window"}');

},
testWindowCommand : function(test) {

@@ -567,3 +609,3 @@ var client = this.client;

);
test.throws(

@@ -574,6 +616,6 @@ function() {

);
});
},
testWindowSizeErrors : function(test) {

@@ -587,3 +629,3 @@ var client = this.client;

);
test.throws(

@@ -593,4 +635,4 @@ function() {

}, 'Width and height arguments must be passed as numbers.'
);
);
test.throws(

@@ -601,3 +643,3 @@ function() {

);
test.throws(

@@ -611,3 +653,3 @@ function() {

},
testWindowSizeGet : function(test) {

@@ -619,8 +661,8 @@ var client = this.client;

});
test.equal(command.request.method, 'GET');
test.equal(command.request.path, '/wd/hub/session/1352110219202/window/current/size');
test.equal(command.request.path, '/wd/hub/session/1352110219202/window/current/size');
});
},
testWindowSizePost : function(test) {

@@ -632,12 +674,12 @@ var client = this.client;

});
test.equal(command.request.method, 'POST');
test.equal(command.data, '{"width":10,"height":10}');
test.equal(command.request.path, '/wd/hub/session/1352110219202/window/current/size');
test.equal(command.request.path, '/wd/hub/session/1352110219202/window/current/size');
});
},
testAcceptAlert : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -647,3 +689,3 @@ var command = protocol.actions.accept_alert.call(client, function callback() {

});
test.equal(command.request.method, 'POST');

@@ -653,6 +695,6 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/accept_alert');

},
testDismissAlert : function(test) {
var client = this.client;
this.client.on('selenium:session_create', function(sessionId) {

@@ -662,3 +704,3 @@ var command = protocol.actions.dismiss_alert.call(client, function callback() {

});
test.equal(command.request.method, 'POST');

@@ -668,3 +710,3 @@ test.equal(command.request.path, '/wd/hub/session/1352110219202/dismiss_alert');

},
tearDown : function(callback) {

@@ -671,0 +713,0 @@ this.client = null;

Sorry, the diff of this file is not supported yet

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