nhrcpt
nhrcpt

Reputation: 872

Protractor: Page Object returns "promise" instead of Text

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

Answers (1)

Kuba Lubas
Kuba Lubas

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

Related Questions