nightwatch
Version:
Easy to use Node.js based end-to-end testing solution for web applications using the W3C WebDriver API.
31 lines (23 loc) • 758 B
JavaScript
const CommandLoader = require('./command.js');
const ElementCommand = require('../../element').Command;
class ElementCommandLoader extends CommandLoader {
static createInstance(CommandModule, opts) {
let ClassName = CommandModule || ElementCommand;
return new ClassName(opts);
}
createWrapper() {
if (this.module) {
this.commandFn = function commandFn({args, stackTrace}) {
const instance = ElementCommandLoader.createInstance(this.module, {
args,
commandName: this.commandName,
nightwatchInstance: this.nightwatchInstance
});
instance.stackTrace = stackTrace;
return instance.command();
};
}
return this;
}
}
module.exports = ElementCommandLoader;