getLocationAbsUrl()
does not (always) return $location.absUrl()
#3185
Description
Bug report
-
Protractor Version:
3.3.0
-
A relevant example test
browser.get('http://angular.github.io/protractor/#/api'); expect(browser.getLocationAbsUrl()).toBe('http://angular.github.io/protractor/#/api');
-
Output from running the test
Expected
/api
to equal'http://angular.github.io/protractor/#/api'
.
As seen in protractor.ts#L864-L869 and clientsidescripts.js#L651-L658, the return value of getLocationAbsUrl()
is different when angular.getTestability
is available and most importantly it is not the absUrl
(in the $location
sense).
Basically, when angular.getTestability
is not available, $location.absUrl()
is returned (which is the expected behavior). But when angular.getTestability
is available (i.e. since AngularJS v1.3.0-rc.0 - see angular.js#85880a6), $location.url()
is returned instead (because that is what $$testability
returns).
This is the case since at least Protractor v1.1.1 (see 0e9c2f4).
Returning $location.url()
from a function named getLocationAbsUrl()
isn't very intuitive, but this has been the case for a long time. For the next breaking release, it might be a good idea to expose two methods (on Protractor and $$testability
) to retrieve both the .url()
and the .absUrl()
, e.g. getLocationUrl()
and getLocationAbsUrl()
.