I have a decent idea of how the $q library in angular works but I\'m not sure how protractor or web-driver-js uses them. (especially since the utilizations are slightly diff
Here is a good article about Protractor control flow, itself inspired by the WebDriver API.
In short (quoting the article), here is how the ControlFlow of WebDriver works under the hood.
When you write:
driver.get('http://www.example.com');
driver.findElement(elem).sendKeys('hello');
What actually happens is:
driver.get('http://www.example.com')
.then(function() {
return driver.findElement(elem);
})
.then(function(q) {
return q.sendKeys('hello');
});