testarmada-nightwatch-extra
Advanced tools
Comparing version 1.2.0-beta2 to 1.2.0-beta3
@@ -15,2 +15,8 @@ var EventEmitter = require("events").EventEmitter; | ||
this.failureMessage = ""; | ||
this.time = { | ||
totalTime: 0, | ||
seleniumCallTime: 0, | ||
executeAsyncTime: 0 | ||
}; | ||
}; | ||
@@ -46,5 +52,5 @@ | ||
BaseAssertion.prototype.pass = function (actual, expected, message) { | ||
var elapsed = (new Date()).getTime() - this.startTime; | ||
this.time.totalTime = (new Date()).getTime() - this.startTime; | ||
this.client.assertion(true, actual, expected, util.format(message, this.time.totalTime), true); | ||
this.client.assertion(true, actual, expected, util.format(message, elapsed), true); | ||
statsd({ | ||
@@ -54,3 +60,3 @@ capabilities: this.client.options.desiredCapabilities, | ||
cmd: this.cmd, | ||
value: elapsed | ||
value: this.time | ||
}); | ||
@@ -57,0 +63,0 @@ |
@@ -33,2 +33,5 @@ // Assert whether a selector contains a given text | ||
spacing caused by the DOM */ | ||
var elapse = (new Date()).getTime(); | ||
self.time.executeAsyncTime = elapse - self.startTime; | ||
self.time.seleniumCallTime = 0; | ||
self.assert(result.value.value.replace(/[\s|\n]+/g, ' '), self.expected); | ||
@@ -35,0 +38,0 @@ }); |
@@ -30,2 +30,5 @@ var util = require("util"), | ||
function (result) { | ||
var elapse = (new Date()).getTime(); | ||
self.time.executeAsyncTime = elapse - self.startTime; | ||
self.time.seleniumCallTime = 0; | ||
self.assert(result.value.value, self.lengthToCompare); | ||
@@ -32,0 +35,0 @@ }); |
@@ -31,2 +31,5 @@ // Assert whether a selector contains a given text | ||
function (result) { | ||
var elapse = (new Date()).getTime(); | ||
self.time.executeAsyncTime = elapse - self.startTime; | ||
self.time.seleniumCallTime = 0; | ||
self.assert(result.value.value, self.expected); | ||
@@ -33,0 +36,0 @@ }); |
@@ -31,2 +31,5 @@ // Assert whether a selector contains a given text | ||
function (result) { | ||
var elapse = (new Date()).getTime(); | ||
self.time.executeAsyncTime = elapse - self.startTime; | ||
self.time.seleniumCallTime = 0; | ||
self.assert(result.value.value, self.expected); | ||
@@ -33,0 +36,0 @@ }); |
@@ -31,2 +31,5 @@ // Assert whether a selector has a given expected query result length | ||
function (result) { | ||
var elapse = (new Date()).getTime(); | ||
self.time.executeAsyncTime = elapse - self.startTime; | ||
self.time.seleniumCallTime = 0; | ||
self.assert(result.value.value, self.expected); | ||
@@ -33,0 +36,0 @@ }); |
@@ -14,5 +14,11 @@ var util = require("util"); | ||
EventEmitter.call(this); | ||
this.startTime = null; | ||
this.startTime = 0; | ||
this.successMessage = ""; | ||
this.failureMessage = ""; | ||
this.time = { | ||
totalTime: 0, | ||
seleniumCallTime: 0, | ||
executeAsyncTime: 0 | ||
}; | ||
}; | ||
@@ -34,5 +40,6 @@ | ||
innerArgs.push(settings.SEEN_MAX); | ||
this.client.api | ||
.executeAsync(fn, innerArgs, function (result) { | ||
if (settings.verbose) { | ||
@@ -78,4 +85,5 @@ console.log("execute(" + innerArgs + ") intermediate result: ", result); | ||
var pactual = pexpected = actual || "visible"; | ||
var elapsed = (new Date()).getTime() - this.startTime; | ||
this.client.assertion(true, pactual, pexpected, util.format(this.successMessage, elapsed), true); | ||
this.time.totalTime = (new Date()).getTime() - this.startTime; | ||
this.client.assertion(true, pactual, pexpected, util.format(this.successMessage, this.time.totalTime), true); | ||
statsd({ | ||
@@ -85,3 +93,3 @@ capabilities: this.client.options.desiredCapabilities, | ||
cmd: this.cmd, | ||
value: elapsed | ||
value: this.time | ||
}); | ||
@@ -99,4 +107,4 @@ | ||
var pexpected = expected || "visible"; | ||
var elapsed = (new Date()).getTime() - this.startTime; | ||
this.client.assertion(false, pactual, pexpected, util.format(this.failureMessage, elapsed), true); | ||
this.time.totalTime = (new Date()).getTime() - this.startTime; | ||
this.client.assertion(false, pactual, pexpected, util.format(this.failureMessage, this.time.totalTime), true); | ||
if (this.cb) { | ||
@@ -103,0 +111,0 @@ this.cb.apply(this.client.api, []); |
@@ -16,3 +16,4 @@ var util = require("util"); | ||
var self = this; | ||
var now = (new Date()).getTime(); | ||
this.time.executeAsyncTime = now - self.startTime; | ||
this.client.api | ||
@@ -23,2 +24,3 @@ .clearValue( | ||
function () { | ||
self.time.seleniumCallTime = (new Date()).getTime() - now; | ||
self.pass(); | ||
@@ -25,0 +27,0 @@ }); |
@@ -24,6 +24,10 @@ var util = require("util"); | ||
var self = this; | ||
var now = (new Date()).getTime(); | ||
this.time.executeAsyncTime = now - self.startTime; | ||
this.client.api.click( | ||
"css selector", | ||
"css selector", | ||
"[data-magellan-temp-automation-id='" + magellanSel + "']", | ||
function () { | ||
self.time.seleniumCallTime = (new Date()).getTime() - now; | ||
self.pass(); | ||
@@ -30,0 +34,0 @@ }); |
@@ -29,3 +29,2 @@ var util = require("util"); | ||
// Keep a running count of how many times we've seen this element visible | ||
console.log(result) | ||
if (result.isVisible) { | ||
@@ -48,2 +47,6 @@ self.seenCount += 1; | ||
if (self.seenCount >= SEEN_MAX || result.seens >= SEEN_MAX) { | ||
var elapse = (new Date()).getTime(); | ||
self.time.executeAsyncTime = elapse - self.startTime; | ||
self.time.seleniumCallTime = 0; | ||
self.pass(); | ||
@@ -50,0 +53,0 @@ } else { |
@@ -52,2 +52,5 @@ var util = require("util"); | ||
} | ||
var elapse = (new Date()).getTime(); | ||
self.time.executeAsyncTime = elapse - self.startTime; | ||
self.time.seleniumCallTime = 0; | ||
self.pass(ret); | ||
@@ -54,0 +57,0 @@ } else { |
@@ -48,2 +48,6 @@ var util = require("util"); | ||
if (result.seens >= SEEN_MAX || self.seenCount >= SEEN_MAX) { | ||
var elapse = (new Date()).getTime(); | ||
self.time.executeAsyncTime = elapse - self.startTime; | ||
self.time.seleniumCallTime = 0; | ||
self.pass(result.value.value, self.selector); | ||
@@ -50,0 +54,0 @@ } else { |
@@ -16,3 +16,5 @@ var util = require("util"); | ||
var self = this; | ||
var now = (new Date()).getTime(); | ||
this.time.executeAsyncTime = now - self.startTime; | ||
this.client.api | ||
@@ -25,2 +27,3 @@ .moveToElement( | ||
function () { | ||
self.time.seleniumCallTime = (new Date()).getTime() - now; | ||
self.pass(); | ||
@@ -27,0 +30,0 @@ }); |
@@ -16,3 +16,4 @@ var util = require("util"); | ||
var self = this; | ||
var now = (new Date()).getTime(); | ||
this.time.executeAsyncTime = now - self.startTime; | ||
this.client.api | ||
@@ -24,2 +25,3 @@ .setValue( | ||
function () { | ||
self.time.seleniumCallTime = (new Date()).getTime() - now; | ||
self.pass(); | ||
@@ -26,0 +28,0 @@ }); |
@@ -33,2 +33,5 @@ // Safe version of waitForElementNotPresent | ||
if (result.isVisibleStrict === false) { | ||
var elapse = (new Date()).getTime(); | ||
self.time.executeAsyncTime = elapse - self.startTime; | ||
self.time.seleniumCallTime = 0; | ||
self.pass("not present"); | ||
@@ -35,0 +38,0 @@ } else { |
@@ -27,3 +27,7 @@ var util = require("util"); | ||
"cmd": "clickEl", | ||
"value": 300 | ||
"value": { | ||
totalTime: 300, | ||
seleniumCallTime: 180, | ||
executeAsyncTime: 120 | ||
} | ||
} | ||
@@ -47,3 +51,5 @@ */ | ||
client.timing(fullEventKey, event.value); | ||
client.timing(fullEventKey + ".totalTime", event.value.totalTime); | ||
client.timing(fullEventKey + ".seleniumCallTime", event.value.seleniumCallTime); | ||
client.timing(fullEventKey + ".executeAsyncTime", event.value.executeAsyncTime); | ||
}; |
{ | ||
"name": "testarmada-nightwatch-extra", | ||
"version": "1.2.0-beta2", | ||
"version": "1.2.0-beta3", | ||
"description": "extra useful nightwatch command and assertion", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
92959
38
1768