Protractor 如何使用量角器测试从API获取数据的表
在Angular8项目中,我想用量角器测试一个包含从API获得的数据的表 在我的HTML页面中:Protractor 如何使用量角器测试从API获取数据的表,protractor,e2e-testing,angular8,Protractor,E2e Testing,Angular8,在Angular8项目中,我想用量角器测试一个包含从API获得的数据的表 在我的HTML页面中: <tr *ngFor="let pop of popList" class="pops-list"> <td>{{pop.name}}</td> <td class="pop-description">{{pop.description}}</td> <td>{{pop
<tr *ngFor="let pop of popList" class="pops-list">
<td>{{pop.name}}</td>
<td class="pop-description">{{pop.description}}</td>
<td>{{pop.id}}</td>
<td>{{pop.area}}</td>
<td>{{pop.timeZone}}</td>
</tr>
在我的测试中,我尝试:
await element.all(by.repeater('pop in popList')).count().then(count => console.log(count));
count.toEqual(3)给出了错误:
类型“number”上不存在属性“toEqual”
你能帮个忙吗?所以使用async和Wait可以很好地工作,但不确定这是否是最好的方法, 在我的等级库文件中:
it('should be populated with list data', async () => {
await page.navigateToAdministration();
let popList = await element.all(by.css('table .pops-list'));
expect(popList.length).toBe(41);
});
it('should display correct POP names', async () => {
await page.navigateToAdministration();
const popItems = await element.all(by.css('.pops-list')).all(by.css('.pop-name'));
expect(popItems[0].getText()).toEqual('AMI');
expect(popItems[1].getText()).toEqual('ANN');
expect(popItems[2].getText()).toEqual('AUB');
});
我在html中添加了一些css类以供选择
it('should be populated with list data', async () => {
await page.navigateToAdministration();
let popList = await element.all(by.css('table .pops-list'));
expect(popList.length).toBe(41);
});
it('should display correct POP names', async () => {
await page.navigateToAdministration();
const popItems = await element.all(by.css('.pops-list')).all(by.css('.pop-name'));
expect(popItems[0].getText()).toEqual('AMI');
expect(popItems[1].getText()).toEqual('ANN');
expect(popItems[2].getText()).toEqual('AUB');
});