Reputation: 872
I have this page object method :
this.userName = async function(){
if(environment === 'AWS'){
return 'user1'
}else{
return'user2'
}
};
When the script is run, it returns the following:
Promise { 'user1' }
Is there a way to return only the text "user1", not as a promise?
Upvotes: 0
Views: 36
Reputation: 91
Rewrite it to:
// option 1
this.userName = await async function(){
// option 2
this.userName = function(){
// and rest of the code
if(environment === 'AWS'){
return 'user1'
}else{
return'user2'
}
};
Upvotes: 1