Reputation: 809
When I ran this test:
browser.get('http://www.valid-site.com').then(function(msg){
console.log(msg);
});
I'm expecting 1 or true to be printed to indicate that the operation is successful since get() should return a promise with the value it has been resolved to. Instead it prints 'null'. In the API docs http://angular.github.io/protractor/#/api there is no indication of a return type. I'm confused which functions return a promise and which do not.
Upvotes: 1
Views: 216
Reputation: 473873
Not sure if it would directly answer the question, but, if you look into the browser.get()
protractor's implementation (it wraps the WebDriverJS
's driver.get()
), you can see that it returns:
return this.executeScript_(
'angular.resumeBootstrap(arguments[0]);',
msg('resume bootstrap'),
moduleNames);
And since the executed script has no return
, this is the reason you see null
resolved.
But, if you look into, for example, browser.refresh()
implementation, you'll see that it returns:
return self.executeScript_(
'return window.location.href',
'Protractor.refresh() - getUrl').then(function(href) {
return self.get(href, timeout);
});
In this case, the executed script returns window.location.href
value, which you would see on the console in case:
browser.refresh().then(function (url) {
console.log(url);
});
I guess, you can understand this "Read the source, Luke" answer, as, whenever you are not sure, look into sources.
Upvotes: 4