I have a Protractor call that returns a promise, and the promise wraps a value.
var e = element.all(by.css("selector")).first();
e.getAttribute('id').then(function (text) {
console.log(text);
});
I want to do a blocking wait on the promise returned from getAttribute()
and retrieve the resulting text.
This needs to be a blocking function; adding then
would require rewriting many of our existing tests. How can I write this?
Edit:
What I am trying to do is to retrieve a value from the page and use it to build an element selector. So:
- Find the dynamic ID of element one:
element.all(by.css("...")).first().getAttribute('id')
- Build a selector based on that value:
var elementSelector = '#X' + elementOneID + '-Y';
- Find and do something with element two:
element(by.css(elementSelector))...
I will accept any answer that allows me to do this.
Edit 2:
Apparently this is not possible without a callback. I ended up revising my CSS selectors.