Pages

How to verify page url in protractor ?

urlContains() in protractor ?

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

First check the below page url.


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

Here we are giving time out 5000ms to verify whether url contains given substring.
If url not matches given substring, it will display a time out error like below:
How to verify page url in protractor ?

urlContains() will matches/check a given substring is case sensitive.
urlContains

Please comment below to feedback or ask questions.

No comments:

Post a Comment

Please comment below to feedback or ask questions.