为什么在下面的代码中变量username1未定义? username是有效的howeverand返回预期值:
var AngularHomePage = function() {
this.nameInput = element(by.model('yourName'));
this.greeting = element(by.binding('yourName'));
this.get = function() {
browser.get('http://www.angularjs.org');
};
this.setName = function() {
var username;
var reader = csv.createCsvFileReader('../spece2e/sneh.csv', {
'columnsFromHeader': false,
'separator': ','
});
reader.addListener('data', function(data) {
username = data[0];
console.log('data from csv is: ',username);
//return username;
});
return username;
};
var username1=this.setName();
console.log('data being sent: ',username1);
this.nameInput.sendKeys(username1);
};
module.exports=new AngularHomePage();