我为Angular2应用程序编写了以下量角器测试:
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);
});
});
Run Code Online (Sandbox Code Playgroud)
它一直失败,原因如下: Failed: Cannot read property 'parentElementArrayFinder' of undefined
谁能告诉我为什么我会收到这个错误?我有一个页面,只显示<puppet-summary>
加载后端数据时的元素.这就是为什么我要检查它是否存在(它只在半秒左右后出现).要仅在有数据显示时显示,我使用以下HTML代码:
<div *ngIf="puppetMasters.length">
<puppet-summary></puppet-summary>
</div>
Run Code Online (Sandbox Code Playgroud)
puppetMasters
是一个数组,一旦加载来自后端的数据就会被填充.