Pages

How to get page title in protractor ?

Get page title in protractor ?

In protractor, we will get current web page title using getTitle().

Please check below code script:
describe('Protractor to get current page title', function () {
it('Code script to get current page title', function () {
browser.get("https://keeplearners.blogspot.com/");
var pageTitle = getPageTitle();
expect(pageTitle).toBe("Keep Learning")
});

function getPageTitle() {
return browser.getTitle().then(function (title) {
console.log("Page title=" + title);
return title;
});
}
});
we have used getTitle() with the help of browser global created by protractor.

protractor getTitle()
protractor getTitle()
Please comment below to feedback or ask questions.

No comments:

Post a Comment

Please comment below to feedback or ask questions.