Pages

How to get Current page URL in protractor ?

Protractor how to get current page URL ?

In protractor we will get current web page url using getCurrentUrl().

Please check below code script:

describe('Protractor to get current web page url', function () {
it('Code script to get current web page url', function () {
browser.get("https://keeplearners.blogspot.com/");
var url = getCurrentPageUrl();
expect(url).toBe("https://keeplearners.blogspot.com/")
});

function getCurrentPageUrl() {
return browser.getCurrentUrl().then(function (url) {
console.log("Browser url=" + url);
return url;
});
}
});
we have used getCurrentUrl with the help of browser object.
Protractor getCurrentUrl()

Please comment below to feedback or ask questions.

No comments:

Post a Comment

Please comment below to feedback or ask questions.