Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Protractor 如何使用量角器测试从API获取数据的表_Protractor_E2e Testing_Angular8 - Fatal编程技术网

Protractor 如何使用量角器测试从API获取数据的表

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

在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.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');
  });