Reputation: 31
I am using Protractor. Theres this test im writing: I am waiting for an element to appear. When it appears i'd like to click it. So i've done this:
it("Test", () => {
let k: p.ElementFinder = element(by.className("gift-back"));
browser.wait(() => {
let promise = k.isPresent().then((isPresent: boolean) => {
console.log(isPresent);
return isPresent;
});
return promise;
});
k.click();
The problem is that, the element i am waiting for to appear (the element with class gift-back) is an ng-if element.So this element is not in the DOM all the time and this test is not actually working. Help or warkaround is highly appreciated!
Upvotes: 0
Views: 328
Reputation: 473833
There is a built-in Expected Condition for the "presence" checks, try it:
var EC = protractor.ExpectedConditions;
var elm = element(by.className("gift-back"));
browser.wait(EC.presenceOf(elm), 5000); // wait up to 5 seconds
Upvotes: 1