如何使用 TypeScript 和量角器获取农业网格中的行数

How to get the count of rows in an ag-grid using TypeScript and Protractor

我正在尝试查找农业网格中存在的行数。 Table 结构;看起来像这样:

<div class="ag-body-container" role="presentation" style="height: 500px; top: 0px; width: 1091px;">
<div role="row" row-index="0" row-id="0" comp-id="134" class="ag-row ag-row-no-focus ag-row-even ag-row-no-animation ag-row-level-0" style="height: 50px; top: 0px;  ">
<div role="row" row-index="1" row-id="1" comp-id="140" class="ag-row ag-row-no-focus ag-row-odd ag-row-no-animation ag-row-level-0" style="height: 50px; top: 50px;  ">
<div role="row" row-index="2" row-id="2" comp-id="146" class="ag-row ag-row-no-focus ag-row-even ag-row-no-animation ag-row-level-0" style="height: 50px; top: 100px;  ">
<div role="row" row-index="3" row-id="3" comp-id="152" class="ag-row ag-row-no-focus ag-row-odd ag-row-no-animation ag-row-level-0" style="height: 50px; top: 150px;  ">
<div role="row" row-index="4" row-id="4" comp-id="158" class="ag-row ag-row-no-focus ag-row-even ag-row-no-animation ag-row-level-0" style="height: 50px; top: 200px;  ">


在其他 div 下还有几行具有相同的 class="ag-row ag-row-no-focus ag-row-odd ag-row-no-animation ag-row-level-0"。所以我不能直接用这个 class.

搜索行

感谢任何形式的帮助。

试试这个 css 选择器 div.ag-body-container > [role="row"],它只计算当前视口中的行数。我注意到 ag-Grid 上的演示,当您向下滚动网格时,将显示另一批行。因此,如果您的网格也与此类似,上面的 css 选择器无法获取所有在视口中不可见的数据行。