Pages

Verify the display of element which disappear immediately in protractor

Verify the display of element which disappear immediately in protractor ?

describe('Protractor - Verify the display of element which disappear immediately in protractor', function () {
beforeAll(async function () {
await browser.get("https://keeplearners.blogspot.com/2018/03/Angular-elements.html");
});

it('Verify the display of element which disappear immediately in protractor', async function () {
verifyBlinkMessage(2000, 0, "className");
});

function verifyBlinkMessage(totalCount, currentCount, className) {
if (currentCount < totalCount) {
return browser.executeScript("return document.getElementsByClassName('" + className + "').length").then(function (value) {
if (value > 0) {
console.log("Element displayed=" + value);
return browser.executeScript("return document.getElementsByClassName('" + className + "')[0].innerText").then(function (textPopUp) {
console.log("pop up message=" + textPopUp);
return textPopUp;
// return true;
});
} else {
console.log("Page is loading....");
return verifyBlinkMessage(totalCount, currentCount++, className);
}
});
} else {
throw new Error("element not present after Max count" + totalCount + "ms reached.")
// return false; //if element not present after Max count reached.
}
}
});
Verify the display of element which disappear immediately in protractor

Please comment below to feedback or ask questions.

No comments:

Post a Comment

Please comment below to feedback or ask questions.