We are encountering an issue where we are trying to store a value from the getAttribute function in a local variable, but resolving the promise seems to be problematic for us.
return element(by.id('foo')).getAttribute('value');
This code snippet above returns a promise when executed, and our attempt to store the value using async/await also results in another promise object being returned:
let result = await element(by.id('foo')).getAttribute('value');
We even tried chaining promises to resolve it as shown below:
static async getStreetNumberAsync() {
this.getStreetNumber().then(function(value) {
return new Promise.resolve(value);
});
}
However, waiting for the promise to be resolved did not yield any success. We are seeking guidance on what we might be doing incorrectly and how best to handle this situation.
The complete code excerpt is provided here:
static getStreetNumber(){
return this.MPP().txtStreetNumber.getAttribute('value');
}
static async getStreetNumberAsync() {
let value = await this.getStreetNumber();
return value;
}
static editMyProfile(){
let value = this.getStreetNumberAsync();
}
In the end, the value stored in 'value' appears to be of type promise [object promise]. Any insights or assistance would be greatly appreciated!
Thank you in advance!