Pages

How to verify exact page title in protractor ?

titleIs() in protractor ?

  • titleIs() will verify the current web page title equals to a given string.
  • If title not equals to given string in given time, it will throw time out error.
  • title should be case-sensitive.
Please check below code script:

First check the page title in DOM

describe('Protractor - waits - titleIs()', function () {
beforeAll(
async function () {
await browser.get("https://keeplearners.blogspot.com/");
});
it(
'Code script to use waits - titleIs() in protractor', async function () {
var EC = protractor.ExpectedConditions;
await browser.wait(EC.titleIs("Keep Learning"), 5000, "expected title is not equal to actual title");
await console.log("Exact Title verified");
});
});
Output:
protractor titleIs()
Here we are giving time out 5000ms to verify whether title equals to given string.
If title not equals given string, it will display a time out error like below:
titleIs
titleIs() will check a given string is in case sensitive.

Please comment below to feedback or ask questions.

No comments:

Post a Comment

Please comment below to feedback or ask questions.