nightwatch
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -40,3 +40,3 @@ { | ||
"use_ssl" : false, | ||
"silent" : false, | ||
"silent" : true, | ||
"output" : true, | ||
@@ -51,2 +51,14 @@ "screenshots" : { | ||
} | ||
}, | ||
"browserstack" : { | ||
"selenium_host" : "hub.browserstack.com", | ||
"selenium_port" : 80, | ||
"silent" : true, | ||
"desiredCapabilities": { | ||
"name" : "test-example", | ||
"browserName": "firefox", | ||
"browserstack.user" : "...", | ||
"browserstack.key" : "..." | ||
} | ||
} | ||
@@ -53,0 +65,0 @@ } |
@@ -1,8 +0,8 @@ | ||
var util = require("util"), | ||
var util = require('util'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
events = require("events"), | ||
events = require('events'), | ||
HttpRequest = require('./request.js'), | ||
CommandQueue = require('./queue.js'), | ||
Logger = require("./logger.js"); | ||
Logger = require('./logger.js'); | ||
@@ -20,8 +20,8 @@ function Nightwatch(options) { | ||
this.options.screenshots || (this.options.screenshots = { | ||
"enabled" : false, | ||
"path" : "" | ||
'enabled' : false, | ||
'path' : '' | ||
}); | ||
this.options.output = this.options.output || typeof this.options.output == 'undefined'; | ||
this.screenshotPath = this.options.screenshotPath || ""; | ||
this.screenshotPath = this.options.screenshotPath || ''; | ||
this.isRunning = false; | ||
@@ -52,6 +52,6 @@ this.launch_url = this.options.launch_url || null; | ||
this.desiredCapabilities = { | ||
browserName: "firefox", | ||
browserName: 'firefox', | ||
javascriptEnabled: true, | ||
acceptSslCerts: true, | ||
platform: "ANY" | ||
platform: 'ANY' | ||
}; | ||
@@ -196,3 +196,3 @@ | ||
commandFiles.forEach(function(file) { | ||
if (path.extname(file) == ".js") { | ||
if (path.extname(file) == '.js') { | ||
var command = require(path.join(absPath, file)); | ||
@@ -219,5 +219,5 @@ var name = path.basename(file, '.js'); | ||
var message = typeof arguments[arguments.length-1] == 'string' && | ||
(arguments.length > 2 || typeof arguments[0] === "boolean") && | ||
(arguments.length > 2 || typeof arguments[0] === 'boolean') && | ||
arguments[arguments.length-1] | ||
|| (typeof arguments[0] === "function" && '[Function]') | ||
|| (typeof arguments[0] === 'function' && '[Function]') | ||
|| '' + actual; | ||
@@ -228,6 +228,6 @@ | ||
passed = true; | ||
message = "Assertion passed: " + message; | ||
message = 'Assertion passed: ' + message; | ||
} catch (ex) { | ||
passed = false; | ||
message = "Assertion failed: " + (ex.message || message); | ||
message = 'Assertion failed: ' + (ex.message || message); | ||
actual = ex.actual; | ||
@@ -260,3 +260,3 @@ expected = ex.expected | ||
for (var i = 0, len = commandFiles.length; i < len; i++) { | ||
if (path.extname(commandFiles[i]) == ".js") { | ||
if (path.extname(commandFiles[i]) == '.js') { | ||
var commandName = path.basename(commandFiles[i], '.js'); | ||
@@ -275,3 +275,3 @@ var Module = require(path.join(__dirname, relativePath) + commandFiles[i]); | ||
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) | ||
@@ -310,6 +310,16 @@ throw error; | ||
var d = new Date(); | ||
var datestamp = d.toLocaleDateString().toLowerCase().replace(/\//g, '-') + '--' + d.toLocaleTimeString() | ||
var datestamp = d.toLocaleString('en-GB', { | ||
weekday: 'narrow', | ||
year: 'numeric', | ||
month: '2-digit', | ||
day: '2-digit', | ||
timeZoneName : 'short', | ||
hour : '2-digit', | ||
minute : '2-digit', | ||
second : '2-digit', | ||
era : 'short' | ||
}).replace(/\:/g,'').replace(/\s/g,'-').replace(/-\(.+?\)/,''); | ||
var fileName = path.join(self.options.screenshots.path, 'ERROR_' + datestamp + '.png'); | ||
self.saveScreenshotToFile(fileName, screenshotContent) | ||
self.saveScreenshotToFile(fileName, screenshotContent); | ||
} | ||
@@ -322,3 +332,3 @@ | ||
try { | ||
if (typeof callback != "function") { | ||
if (typeof callback != 'function') { | ||
var error = new Error('Callback parameter is not a function - ' + typeof(callback) + ' passed: "' + callback + '"'); | ||
@@ -364,3 +374,3 @@ this.errors.push(error.stack) | ||
var self = this; | ||
return this.runCommand("element", [using, value, function(result) { | ||
return this.runCommand('element', [using, value, function(result) { | ||
if (result.status == 0) { | ||
@@ -379,3 +389,3 @@ callback.call(self, result.value.ELEMENT, result); | ||
if (this.options.output) { | ||
console.log(Logger.colors.green("✔") + " " + message); | ||
console.log(Logger.colors.green('✔') + ' ' + message); | ||
} | ||
@@ -392,5 +402,5 @@ this.results.passed++; | ||
} catch (ex) { | ||
var logged = Logger.colors.red("✖") + " " + message; | ||
if (typeof expectedValue != "undefined" && typeof receivedValue != "undefined") { | ||
logged += " " + Logger.colors.white(' - expected "' + Logger.colors.green(expectedValue)) + '" but got: ' + Logger.colors.red(receivedValue); | ||
var logged = Logger.colors.red('✖') + ' ' + message; | ||
if (typeof expectedValue != 'undefined' && typeof receivedValue != 'undefined') { | ||
logged += ' ' + Logger.colors.white(' - expected "' + Logger.colors.green(expectedValue)) + '" but got: ' + Logger.colors.red(receivedValue); | ||
} | ||
@@ -419,5 +429,7 @@ | ||
Nightwatch.prototype.saveScreenshotToFile = function(fileName, content) { | ||
fs.writeFile(fileName, content, "base64", function(err) { | ||
if (err) { | ||
Logger.error(err); | ||
fs.writeFile(fileName, content, 'base64', function(err) { | ||
if (err) { | ||
console.log(Logger.colors.yellow('Couldn\'t save screenshot to '), fileName); | ||
Logger.warn(err); | ||
} | ||
@@ -431,3 +443,3 @@ }); | ||
var errorCodes = require('./selenium/errors.json'); | ||
errorMessage = errorCodes[result.status].message || ""; | ||
errorMessage = errorCodes[result.status].message || ''; | ||
} | ||
@@ -448,3 +460,3 @@ | ||
var request = new HttpRequest({ | ||
path : "/session", | ||
path : '/session', | ||
data : { | ||
@@ -459,10 +471,10 @@ desiredCapabilities : this.desiredCapabilities, | ||
self.sessionId = data.sessionId; | ||
Logger.info("Got sessionId from selenium", self.sessionId); | ||
Logger.info('Got sessionId from selenium', self.sessionId); | ||
self.emit('selenium:session_create', self.sessionId, request, response); | ||
} else { | ||
Logger.warn("Couldn't retrieve a new session from selenium server."); | ||
Logger.warn('Couldn\'t retrieve a new session from selenium server.'); | ||
} | ||
}) | ||
.on('error', function(data, err) { | ||
console.error(Logger.colors.red("Connection refused!"), "Is selenium server started?"); | ||
console.error(Logger.colors.red('Connection refused!'), 'Is selenium server started?'); | ||
self.emit('error', data, err); | ||
@@ -469,0 +481,0 @@ }) |
{ | ||
"name": "nightwatch", | ||
"description": "A node.js bindings implementation for selenium 2.0/webdriver", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"author": { | ||
@@ -25,6 +25,8 @@ "name": "Andrei Rusu", | ||
"devDependencies": { | ||
"nodeunit" : "latest" | ||
"nodeunit": "latest" | ||
}, | ||
"bin" : { "nightwatch" : "./bin/nightwatch" }, | ||
"man" : "", | ||
"bin": { | ||
"nightwatch": "./bin/nightwatch" | ||
}, | ||
"man": "", | ||
"scripts": { | ||
@@ -31,0 +33,0 @@ "test": "node ./tests/run_tests.js" |
@@ -261,3 +261,3 @@ /** | ||
var module = require(modulePath); | ||
var moduleName = modulePath.split('/').pop(); | ||
var moduleName = modulePath.split(path.sep).pop(); | ||
globalresults.modules[moduleName] = []; | ||
@@ -264,0 +264,0 @@ console.log('\n' + Logger.colors.cyan('[ ' + moduleName + ' module ]')); |
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
47531331
99
3706