Reputation: 885
I wrote the following protractor test for an Angular2 app:
describe('Puppet container', () => {
beforeEach(() => {
browser.get('/#/puppet');
});
it('should display puppet summary', () => {
browser.wait($('puppet-summary').isPresent, 1000);
const subject = $('puppet-summary').isDisplayed();
const result = true;
expect(subject).toEqual(result);
});
});
It keeps failing with the following reason: Failed: Cannot read property 'parentElementArrayFinder' of undefined
Can anybody tell me why I'm getting this error? I have a page which only shows the <puppet-summary>
element when the data from the backend is loaded. That's why I'm checking for it to be present (it only becomes present after half a second or so). To show it only if there is data to display, I'm using the following HTML code:
<div *ngIf="puppetMasters.length">
<puppet-summary></puppet-summary>
</div>
puppetMasters
is an array which gets filled as soon as the data from the backend is loaded.
Upvotes: 4
Views: 5029
Reputation: 966
Please try the below function . it will wait until the given html object is present.
browser.wait(function() {
return element(by.css("#edudrop1")).isPresent()});
Upvotes: 0
Reputation: 473823
browser.wait($('puppet-summary').isPresent, 1000);
The "wait for an element to be present" should be done via the built-in presenceOf
Expected Condition:
var EC = protractor.ExpectedConditions;
var elm = $('puppet-summary');
browser.wait(EC.presenceOf(elm), 1000);
Upvotes: 5
Reputation: 2460
I suggest to have a look into this site to find all element locators, conditions, ... And for element is present you can see this example : element(locator).isPresent
Upvotes: 0