From 9d81f8d68b55247dc815c4d1d7630617a3f790d3 Mon Sep 17 00:00:00 2001 From: beatfactor Date: Mon, 17 Mar 2014 15:23:26 +0100 Subject: [PATCH 1/4] trying to make the angular bootstrap deffering to work in chrome --- lib/selenium/client-commands.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/selenium/client-commands.js b/lib/selenium/client-commands.js index 9d781e68ed..745eeea892 100644 --- a/lib/selenium/client-commands.js +++ b/lib/selenium/client-commands.js @@ -405,7 +405,7 @@ module.exports = function(client) { * @since v0.4.0 */ initNgMockApp : function(mainUrl, opts, mocks, passThrough) { - var addDeferBootstrap = function() {/*! jshint browser:true */return (function(w){w.name='NG_DEFER_BOOTSTRAP!'+w.name;})(window);}; + var addDeferBootstrap = function(mainUrl) {/*! jshint browser:true */return (function(w){w.name='NG_DEFER_BOOTSTRAP!'+w.name;location.href=mainUrl;})(window);}; var scriptUrl = opts.scriptUrl; var ngApp = opts.ngApp; @@ -426,8 +426,8 @@ module.exports = function(client) { '}).apply(null, passedArgs)'; return this.url('about:blank', function() { - this.execute(addDeferBootstrap, [], function() { - this.url(mainUrl, function() { + this.execute(addDeferBootstrap, [mainUrl], function() { + this.pause(1000, function() { this.injectScript(scriptUrl, function() { this.execute(bootstrapFn, [ngApp,passThrough]); }); From f1e5679947671157bcf97d9132aed14e49283288 Mon Sep 17 00:00:00 2001 From: beatfactor Date: Mon, 17 Mar 2014 15:25:24 +0100 Subject: [PATCH 2/4] Fixed a problem with passing the right context to pause() callback --- lib/selenium/commands/pause.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/selenium/commands/pause.js b/lib/selenium/commands/pause.js index bad83a37ec..5fb0959cec 100644 --- a/lib/selenium/commands/pause.js +++ b/lib/selenium/commands/pause.js @@ -34,7 +34,7 @@ Pause.prototype.command = function(ms, cb) { setTimeout(function() { // if we have a callback, call it right before the complete event if (cb) { - cb.call(self.client); + cb.call(self.client.api); } self.emit('complete'); From 2f3f26d8d737f4f74534fe8570ee6757accb43cc Mon Sep 17 00:00:00 2001 From: beatfactor Date: Thu, 20 Mar 2014 13:06:04 +0100 Subject: [PATCH 3/4] Added stack traces for test error messages --- lib/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 85ab1e7c46..0688955a85 100644 --- a/lib/index.js +++ b/lib/index.js @@ -141,8 +141,13 @@ Nightwatch.prototype.start = function() { this.queue.reset(); this.queue.run(function(error) { if (error) { + var stackTrace = ''; + if (error.stack) { + stackTrace = '\n' + error.stack.split('\n').slice(1).join('\n'); + } + self.results.errors++; - self.errors.push(error.name + ': ' + error.message); + self.errors.push(error.name + ': ' + error.message + stackTrace); self.terminate(); return; } From 599794156831cc433cd92de4d713a0170ff2def2 Mon Sep 17 00:00:00 2001 From: beatfactor Date: Thu, 20 Mar 2014 13:15:17 +0100 Subject: [PATCH 4/4] Fixed custom assertions loading for the assertions written in the constructor declaration style prior to v0.4 --- lib/api.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/api.js b/lib/api.js index e80358e102..1cdb905d7f 100644 --- a/lib/api.js +++ b/lib/api.js @@ -94,16 +94,11 @@ module.exports = new (function() { } // backwards compatibility - var AssertionInstance = function (abortOnFailure, client) { - this.abortOnFailure = abortOnFailure; - this.client = client; - this.api = client.api; - }; - util.inherits(AssertionInstance, events.EventEmitter); - AssertionInstance.prototype.command = assertionFn; + var module = loadCommandModule(assertionFn, client.api, { + abortOnFailure : abortOnFailure + }); - assertion = new AssertionInstance(abortOnFailure, client); - addCommand(commandName, assertion.command, assertion, parent); + addCommand(commandName, module.command, module.context, parent); return assertion; } @@ -190,14 +185,22 @@ module.exports = new (function() { * @param {object} context * @returns {{command: function, context: *}} */ - function loadCommandModule(module, context) { + function loadCommandModule(module, context, addt_props) { var m = {command: null, context: context}; function F() { if (typeof module === 'object') { events.EventEmitter.call(this); } + if (addt_props) { + for (var prop in addt_props) { + if (addt_props.hasOwnProperty(prop)) { + this[prop] = addt_props[prop]; + } + } + } this.client = client; + this.api = client.api; if (typeof module === 'function') { module.call(this); }