I am currently attempting to execute a Nightwatch script that will access a URL, retrieve a value from an input field, and then utilize that value on the next page.
Take a look at the code snippet below:
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();
}
};
In the line
setValue('input[name="first_name"]', first_name)
, the value appears as "undefined."
The issue arises from the fact that the first_name parameter is being updated within a callback function. I require the setValue function to utilize the updated value properly. Any assistance would be greatly appreciated.