Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

In protractor, globally available browser object has two methods:

getLocationAbsUrl()

Returns the current absolute URL from AngularJS.

getCurrentUrl()

Schedules a command to retrieve the URL of the current page.

It is not quite clear and obvious what is the difference between the two. To this very moment, I've been using getCurrentUrl() only.

When should we use getLocationAbsUrl()? Which use-cases does it cover?

I cannot recall anything similar to getLocationAbsUrl() in other selenium language bindings. It looks pretty much protractor-specific.

1 Answer

0 votes
by (62.9k points)

As declared previously the getLocationAbsUrl - returns a full path to the present location.

browser.get('http://angular.github.io/protractor/#/api');

expect(browser.getLocationAbsUrl()).toBe('http://angular.github.io/protractor/#/api');

The getCurrentUrl is used during a promise (schedule) to retrieve the URL of the current page.

Typically, you'd solely use the getCurrentUrl when scheduling.

webdriver.WebDriver.prototype.getCurrentUrl = function()

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...