We have the following problem, we want to store a value from the getAttribute function in a local variable. We try to resolve the promise but it won't work.
return element(by.id('foo')).getAttribute('value');
This will return a promise and we are trying to store the value like
let result = await element(by.id('foo')).getAttribute('value');
But this will only give another promise object back. I also tried to resolve it by chaining promises like this:
static async getStreetNumberAsync() {
this.getStreetNumber().then(function(value) {
return new Promise.resolve(value);
});
}
And then again wait for the promise to be resolved but that didn't work either. Can someone explain what I'm doing wrong and how to handle this? The whole code:
static getStreetNumber(){
return this.MPP().txtStreetNumber.getAttribute('value');
}
static async getStreetNumberAsync() {
let value = await this.getStreetNumber();
return value;
}
static editMyProfile(){
let value = this.getStreetNumberAsync();
}
the value of 'value' will be a promise [object promise]
Thanks in advance!