nightwatch
Advanced tools
Comparing version 0.4.14 to 0.4.15
@@ -247,2 +247,4 @@ /** | ||
} | ||
process.exit(1); | ||
} | ||
@@ -265,4 +267,4 @@ }; | ||
}, function(err) { | ||
selenium.stopServer(); | ||
errorHandler(err); | ||
selenium.stopServer(); | ||
}); | ||
@@ -269,0 +271,0 @@ }); |
@@ -20,8 +20,8 @@ /** | ||
exports.assertion = function(selector, attribute, expected, msg) { | ||
var DEFAULT_MSG = 'Testing if attribute %s of <%s> equals "%s".'; | ||
var MSG_ELEMENT_NOT_FOUND = DEFAULT_MSG + ' ' + 'Element could not be located.'; | ||
var MSG_ATTR_NOT_FOUND = DEFAULT_MSG + ' ' + 'Element does not have a ' + attribute + ' attribute.'; | ||
var MSG_ELEMENT_NOT_FOUND = 'Testing if element <%s> has attribute %s. ' + | ||
'Element or attribute could not be located.'; | ||
this.message = msg || util.format(DEFAULT_MSG, attribute, selector, expected); | ||
this.message = msg || util.format('Testing if element <%s> has attribute: %s = "%s".', selector, attribute, expected); | ||
this.expected = function() { | ||
@@ -36,5 +36,12 @@ return expected; | ||
this.failure = function(result) { | ||
var failed = result === false || result && result.status === -1; | ||
var failed = (result === false) || | ||
// no such element | ||
result && (result.status === -1 || result.value === null); | ||
if (failed) { | ||
this.message = msg || util.format(MSG_ELEMENT_NOT_FOUND, selector, attribute); | ||
var defaultMsg = MSG_ELEMENT_NOT_FOUND; | ||
if (result && result.value === null) { | ||
defaultMsg = MSG_ATTR_NOT_FOUND; | ||
} | ||
this.message = msg || util.format(defaultMsg, attribute, selector, expected); | ||
} | ||
@@ -41,0 +48,0 @@ return failed; |
@@ -19,7 +19,7 @@ /** | ||
exports.assertion = function(selector, expected, msg) { | ||
var DEFAULT_MSG = 'Testing if value of <%s> contains: "%s".'; | ||
var MSG_ELEMENT_NOT_FOUND = DEFAULT_MSG + ' ' + 'Element could not be located.'; | ||
var VALUE_ATTR_NOT_FOUND = DEFAULT_MSG + ' ' + 'Element does not have a value attribute.'; | ||
var MSG_ELEMENT_NOT_FOUND = 'Testing if value of <%s> contains: "%s". ' + | ||
'Element or attribute could not be located.'; | ||
this.message = msg || util.format('Testing if value of <%s> contains: "%s".', selector, expected); | ||
this.message = msg || util.format(DEFAULT_MSG, selector, expected); | ||
this.expected = true; | ||
@@ -34,7 +34,10 @@ | ||
// no such element | ||
result && result.status === -1 || | ||
// element doesn't have a value attribute | ||
result && result.value === null; | ||
result && (result.status === -1 || result.value === null); | ||
if (failed) { | ||
this.message = msg || util.format(MSG_ELEMENT_NOT_FOUND, selector, expected); | ||
var defaultMsg = MSG_ELEMENT_NOT_FOUND; | ||
if (result && result.value === null) { | ||
defaultMsg = VALUE_ATTR_NOT_FOUND; | ||
} | ||
this.message = msg || util.format(defaultMsg, selector, expected); | ||
} | ||
@@ -41,0 +44,0 @@ return failed; |
{ | ||
"name": "nightwatch", | ||
"description": "A node.js bindings implementation for selenium 2.0/webdriver", | ||
"version": "0.4.14", | ||
"version": "0.4.15", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Andrei Rusu", |
@@ -90,2 +90,29 @@ var BASE_PATH = process.env.NIGHTWATCH_COV | ||
'attributeEquals assertion value attribute not found' : function(test) { | ||
var assertionFn = require('../../../'+BASE_PATH+'/selenium/assertions/attributeEquals.js'); | ||
var client = { | ||
options : {}, | ||
api : { | ||
getAttribute : function(cssSelector, attribute, callback) { | ||
callback({ | ||
status : 0, | ||
value : null | ||
}); | ||
} | ||
}, | ||
assertion : function(passed, result, expected, msg, abortOnFailure) { | ||
test.equals(passed, false); | ||
test.equals(result, null); | ||
test.equals(expected, 'main'); | ||
test.equals(msg, 'Testing if attribute role of <.test_element> equals "main". Element does not have a role attribute.'); | ||
test.equals(abortOnFailure, true); | ||
delete assertionFn; | ||
test.done(); | ||
} | ||
}; | ||
Api.init(client); | ||
var m = Api.createAssertion('attributeEquals', assertionFn, true, client); | ||
m._commandFn('.test_element', 'role', 'main'); | ||
}, | ||
tearDown : function(callback) { | ||
@@ -92,0 +119,0 @@ callback(); |
@@ -65,3 +65,3 @@ var BASE_PATH = process.env.NIGHTWATCH_COV | ||
'valueContains assertion not found' : function(test) { | ||
'valueContains assertion element not found' : function(test) { | ||
var assertionFn = require('../../../'+BASE_PATH+'/selenium/assertions/valueContains.js'); | ||
@@ -81,3 +81,3 @@ var client = { | ||
test.equals(expected, true); | ||
test.equals(msg, 'Testing if value of <.test_element> contains: "some-value". Element or attribute could not be located.'); | ||
test.equals(msg, 'Testing if value of <.test_element> contains: "some-value". Element could not be located.'); | ||
test.equals(abortOnFailure, true); | ||
@@ -93,2 +93,29 @@ delete assertionFn; | ||
'valueContains assertion value attribute not found' : function(test) { | ||
var assertionFn = require('../../../'+BASE_PATH+'/selenium/assertions/valueContains.js'); | ||
var client = { | ||
options : {}, | ||
api : { | ||
getValue : function(cssSelector, callback) { | ||
callback({ | ||
status : 0, | ||
value : null | ||
}); | ||
} | ||
}, | ||
assertion : function(passed, result, expected, msg, abortOnFailure) { | ||
test.equals(passed, false); | ||
test.equals(result, null); | ||
test.equals(expected, true); | ||
test.equals(msg, 'Testing if value of <.test_element> contains: "some-value". Element does not have a value attribute.'); | ||
test.equals(abortOnFailure, true); | ||
delete assertionFn; | ||
test.done(); | ||
} | ||
}; | ||
Api.init(client); | ||
var m = Api.createAssertion('valueContains', assertionFn, true, client); | ||
m._commandFn('.test_element', 'some-value'); | ||
}, | ||
tearDown : function(callback) { | ||
@@ -95,0 +122,0 @@ callback(); |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
301413
120
8632
96