Essentially I am playing around with getting a library for preconditions set up (think user creation). As protractor is promise-based and magically does all the wrapping to
It's not enough just to create a protractor.promise
deferred object - you need to tell the control flow about it. This is usually done with protractor.promise.controlFlow().execute()
.
function timeout(ms) {
protractor.promise.controlFlow().execute(function() {
var deferred = protractor.promise.defer();
setTimeout(function() {
console.log('qwer');
deferred.fulfill(true);
}, ms);
return deferred.promise;
});
}
Read through https://code.google.com/p/selenium/source/browse/javascript/webdriver/promise.js for all the magic behind the scenes here.