I am trying to migrate our older nightwatch-cucumber framework to a nightwatch-api one. Everything works apart from the WaitForText custom command. It works on the old instance however.
This is the error it gives me when it tries to run the custom command:
Error while running "WaitForText" command: Cannot read property 'isES6Async' of undefined
TypeError: Error while running "WaitForText" command: Cannot read property 'isES6Async' of undefined
at queuedCommandFn (/home/kieran/Documents/automation/updated-framework/node_modules/nightwatch/lib/api/_loaders/command.js:195:35)
at CommandInstance.WaitForText.check (/home/kieran/Documents/automation/updated-framework/lib/CustomCom/WaitForText.js:34:5)
at CommandInstance.WaitForText.command (/home/kieran/Documents/automation/updated-framework/lib/CustomCom/WaitForText.js:20:10)
at /home/kieran/Documents/automation/updated-framework/node_modules/nightwatch/lib/api/_loaders/command.js:154:29
at processTicksAndRejections (internal/process/task_queues.js:93:5)
This is the WaitForText.js custom command:
var util = require('util');
var events = require('events');
function WaitForText() {
events.EventEmitter.call(this);
this.startTime = null;
}
util.inherits(WaitForText, events.EventEmitter);
WaitForText.prototype.command = function (element, getter, checker, ms) {
this.startTime = new Date().getTime();
var self = this;
var message;
if (typeof ms !== 'number') {
ms = 1000;
}
this.check(element, getter, checker, function (result, loadedMs) {
if (result) {
message = 'Expression was true after ' + (loadedMs - self.startTime) + ' ms.';
} else {
message = 'Expression wasn\'t true in ' + ms + ' ms.';
}
self.client.assertion(result, 'expression false', 'expression true', message, true);
self.emit('complete');
}, ms);
return this;
};
WaitForText.prototype.check = function (element, getter, checker, cb, maxTime) {
var self = this;
getter(element, function (result) {
var now = new Date().getTime();
if (result.status === 0 && checker(result.value)) {
cb(true, now);
} else if (now - self.startTime < maxTime) {
setTimeout(function () {
self.check(element, getter, checker, cb, maxTime);
}, 1000);
} else {
cb(false);
}
});
};
module.exports = WaitForText;
I don't know where to begin as I don't understand how the custom command works, it was already included with the previous framework.
I am trying to migrate our older nightwatch-cucumber framework to a nightwatch-api one. Everything works apart from the WaitForText custom command. It works on the old instance however.
This is the error it gives me when it tries to run the custom command:
This is the WaitForText.js custom command:
I don't know where to begin as I don't understand how the custom command works, it was already included with the previous framework.
Any help would be greatly appreciated.