nightwatch
Advanced tools
Comparing version 0.6.5 to 0.6.6
module.exports = { | ||
disabled : true, | ||
'Demo test NightwatchJS.org' : function (client) { | ||
@@ -3,0 +4,0 @@ client |
var util = require('util'); | ||
var events = require('events'); | ||
var Logger = require('../../util/logger.js'); | ||
@@ -21,3 +22,4 @@ var formatRegExp = /%[sdj%]/g; | ||
this.locateStrategy = this.client.locateStrategy || 'css selector'; | ||
this.rescheduleInterval = this.client.api.globals.waitForConditionPollInterval || 500; //ms | ||
this.rescheduleInterval = this.client.api.globals.waitForConditionPollInterval || this.client.options.waitForConditionPollInterval || 500; //ms | ||
this.throwOnMultipleElementsReturned = this.client.api.globals.throwOnMultipleElementsReturned || this.client.options.throwOnMultipleElementsReturned || false; | ||
this.protocol = require('../protocol.js')(this.client); | ||
@@ -203,6 +205,16 @@ } | ||
var self = this; | ||
this.protocol.element(this.locateStrategy, this.selector, function(result) { | ||
this.protocol.elements(this.locateStrategy, this.selector, function(result) { | ||
var now = new Date().getTime(); | ||
if (result.status === 0) { | ||
self.element = result.value.ELEMENT; | ||
if (result.value && result.value.length > 0) { | ||
if (result.value.length > 1) { | ||
var message = 'WaitForElement found ' + result.value.length + ' elements for selector "' + self.selector + '".'; | ||
if (self.throwOnMultipleElementsReturned) { | ||
throw new Error(message); | ||
} else if (self.client.options.output) { | ||
console.log(Logger.colors.green(' Warn: ' + message + ' Only the first one will be checked.')); | ||
} | ||
} | ||
self.element = result.value[0].ELEMENT; | ||
return self.elementFound(result, now); | ||
@@ -209,0 +221,0 @@ } |
var util = require('util'); | ||
var Settings = { | ||
log_timestamp : false, | ||
colors : true, | ||
enabled : true | ||
@@ -92,3 +93,7 @@ }; | ||
function logObject(obj) { | ||
console.log(util.inspect(obj, false, 3, true)); | ||
console.log(util.inspect(obj, { | ||
showHidden : false, | ||
depth : 3, | ||
colors : Settings.colors | ||
})); | ||
} | ||
@@ -175,2 +180,3 @@ | ||
exports.disableColors = function () { | ||
Settings.colors = false; | ||
Object.keys(ConsoleColor.prototype).forEach(function (color) { | ||
@@ -177,0 +183,0 @@ ConsoleColor.prototype[color] = function (text) { |
{ | ||
"name": "nightwatch", | ||
"description": "A node.js bindings implementation for selenium 2.0/webdriver", | ||
"version": "0.6.5", | ||
"version": "0.6.6", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Andrei Rusu", |
@@ -75,2 +75,17 @@ { | ||
{ | ||
"url" : "/wd/hub/session/1352110219202/elements", | ||
"postdata" : "{\"using\":\"css selector\",\"value\":\"#weblogin\"}", | ||
"response" : "{\"sessionId\":\"1352110219202\",\"status\":0,\"value\":[{\"ELEMENT\":\"0\"}],\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":604376696}" | ||
}, | ||
{ | ||
"url" : "/wd/hub/session/1352110219202/elements", | ||
"postdata" : "{\"using\":\"css selector\",\"value\":\"#weblogin-multiple\"}", | ||
"response" : "{\"sessionId\":\"1352110219202\",\"status\":0,\"value\":[{\"ELEMENT\":\"0\"},{\"ELEMENT\":\"1\"}],\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":604376696}" | ||
}, | ||
{ | ||
"url" : "/wd/hub/session/1352110219202/elements", | ||
"postdata" : "{\"using\":\"xpath\",\"value\":\"//weblogin\"}", | ||
"response" : "{\"sessionId\":\"1352110219202\",\"status\":0,\"value\":[{\"ELEMENT\":\"0\"}],\"class\":\"org.openqa.selenium.remote.Response\",\"hCode\":604376696}" | ||
}, | ||
{ | ||
"url" : "/wd/hub/session/1352110219202/buttondown", | ||
@@ -77,0 +92,0 @@ "postdata" : "{\"button\":0}", |
@@ -8,3 +8,3 @@ module.exports = { | ||
client.globals.test.equals(result.status, 0); | ||
client.globals.test.deepEqual(result.value, { ELEMENT: '0' }); | ||
client.globals.test.deepEqual(result.value, [ { ELEMENT: '0' } ]); | ||
}) | ||
@@ -11,0 +11,0 @@ .useCss() |
@@ -14,3 +14,3 @@ var MockServer = require('mockserver'); | ||
test.equal(result.status, 0); | ||
test.equal(result.value.ELEMENT, '0'); | ||
test.equal(result.value[0].ELEMENT, '0'); | ||
test.done(); | ||
@@ -17,0 +17,0 @@ }); |
442682
12948