Pages

How to wait for text present in element in protractor ?

textToBePresentInElement() in protractor ?

  • textToBePresentInElement() will checking if the given text is present in the element
Please check below code script:

First check the web element in DOM

verify text present in element


Here we have one button it has text "Click Me"
describe('Protractor - waits - textToBePresentInElement()', function () {
beforeAll(
async function () {
await browser.get("https://keeplearners.blogspot.com/2018/03/Angular-elements.html");
});
it(
'Code script to use waits - textToBePresentInElement() in protractor', async function () {
var EC = protractor.ExpectedConditions;
var clickMeButton = element(by.css("button[ng-click='clickMe(angularAlert)']"));
await browser.wait(EC.
textToBePresentInElement(clickMeButton, 'Click Me'), 5000);
await console.log("Verified that text is present in element");
});
});
Output:
 
verify text is present in element
textToBePresentInElement() in protractor
Please comment below to feedback or ask questions.

No comments:

Post a Comment

Please comment below to feedback or ask questions.