0 votes
1 view
in Devops and Agile by (23.1k 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 (58.7k 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()

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...