Pages

How to verify exact page url in protractor ?

urlIs() in protractor ?

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

First check the page url

describe('Protractor - waits - urlIs()', function () {
beforeAll(
async function () {
await browser.get("https://keeplearners.blogspot.com/");
});
it(
'Code script to use waits - urlIs() in protractor', async function () {
var EC = protractor.ExpectedConditions;
await browser.wait(EC.urlIs("https://keeplearners.blogspot.com/"), 5000, "expected url is not equals to actual url");
await console.log("Current page url verified");
});
});
Output:
urlIs() in protractor

Here we are giving time out 5000ms to verify whether url is equals to given string.
If url not equals given string, it will display a time out error like below:
urlIs()

urlIs() will check a given string is in case sensitive.
verify url in protractor

Please comment below to feedback or ask questions.

No comments:

Post a Comment

Please comment below to feedback or ask questions.