I am calling deferred.fulfill() with a Protractor elementfinder as a parameter. When placing a breakpoint on the fulfill I can see that the elementfinder \"solutionElement\" is
I usually use the map, filter, action/assert pattern. It looks something like this:
element.all(locator).map(function(elm, index) {
// Get the value you are interested in finding and return the element too.
return {
elm: elm,
text: elm.getText(),
index: index
};
}).then(function(list) {
// Find your text here. Otherwise fail.
for(var i = 0; i<list.length; i++) {
if(list[i].text === name) {
return list[i].elm;
}
}
throw new Error('Solution not found');
}).then(function(elm) {
// Perform an action on the element you found.
elm.click();
});
Map will fully resolve all the promises before the results are passed to the next then
in the chain.