Nightwatch: Passing arguments custom command

Created on 9 Mar 2017  路  2Comments  路  Source: nightwatchjs/nightwatch

Hello,
I am trying to pass arguments in custom commands, but I am wondering if it's possible. I just want to generate a basic "alert" in javascript.
In my scenario I have : browser.alertDetresse("Push button !");
And the custom command is :

exports.command = function(msg, callback) {
this.execute(
function reception(msg){
var r = alert(msg);
});
return this;

};

I have the alert message but the message is "undefined".
Thanks in advance for your help,

Most helpful comment

This is not an issue (you should use mailling list or stackoverflow for questions ...), by the way you must respect the prototype of execute command to pass arguments.

exports.command = function(msg, callback) {
this.execute( function reception(msg){
 var r = alert(arguments[0]);
}, [msg]);
return this;
};

All 2 comments

This is not an issue (you should use mailling list or stackoverflow for questions ...), by the way you must respect the prototype of execute command to pass arguments.

exports.command = function(msg, callback) {
this.execute( function reception(msg){
 var r = alert(arguments[0]);
}, [msg]);
return this;
};

Sorry :s And thank you, it worked!

Was this page helpful?
0 / 5 - 0 ratings