Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Fixed test spec
it('Should display the right number of elements on the page', function(){
// myExpectedObjects is an array of items i'm expecting to be
// drawn on the page
var allPromises = myExpectedObjects.map(function(myObject){
return element(by.id(myObject.id)).isPresent();
});
// Wait until all locators have been executed
protractor.promise.all(allPromises).then(function(presentValues){
for(var i = 0; i < presentValues.length; i++){
if(!presentValues[i]){
console.log('Whoops, looks like ' + myExpectedObjects[i].name + ' isn\'t on the page!!');
}
expect(presentValues[i]).toBeTruthy();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment