var readline = require('readline');
var test
rl = readline.createInterface(process.stdin, process.stdout);
rl.question('What is your favorite food?', function(answer) {
console.log('Oh, so your favorite food is ' + answer);
test = answer
});
rl.close()
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
console.log(test) //undefined, why?
So I don't get it why it shows me "undefined" instead of the string I enter thru terminal. Why is that?
My guess is this is not sync, but how do I make it sync?
Modified the code:
var readlineSync = require('readline-sync'); var test webdriverio .remote(options) .init() .url('http://www.google.com').then(function() { test = readlineSync.question('What is your favorite food?'); //Honeyberry console.log(test) //Honeyberry })
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.