I'm trying to run Nightwatch script which will open a url, then it will getValue from an Input and will use that value in the next page.
Please see the following code:
var conf = require('../../nightwatch.conf.BASIC.js');
module.exports = {
'nightwatch flow': function (browser) {
var first_name;
browser
.url('http://example:3000')
.getValue('input[name="first_name"]', function(result){
first_name = result.value;
})
.setValue('input[name="amount"]', 101)
.click('input[name=continue]')
.clearValue('input[name="first_name"]')
.setValue('input[name="first_name"]', first_name)
.click('button[name=next]')
.end();
}
};
the setValue('input[name="first_name"]', first_name)
gets "undefined"
first_name parameter is being updated inside a callback function. I need that setValue function will use the updated value. Thanks in advance