我正在尝试计算表格的行数,下面是HTML
<tr id="resultsRepeaterGrid">
<tr id="tableheader"></tr>
<tr id="Data list1_datarow class = row">
<div style>row 1</div>
<tr id = "expanded row"></tr>
</tr>
<tr id="Data list2_datarow class= altrow">
<div style>row 2</div>
<tr id = "expanded row"></tr>
</tr>
<tr id="Data list3_datarow class = row">
<div style>row 1</div>
<tr id = "expanded row"></tr>
</tr>
</tr>
&#13;
我想得到表的总计数行,丢弃表头和扩展行。我曾尝试过以下代码:
searchRes = element(by.id('resultsRepeaterGrid')); //grid to be displayed
browser.wait(EC.presenceOf(searchRes), 30000);
var searchResCount = element.all(by.css('#resultsRepeaterGrid > tr:not(.tableheader)'));
expect(searchResCount.count()).toEqual(3);
&#13;
但我得到的是预期0等于3.现在我想到了只获取行和altrow类的总数,代码如下:
element.all(by.css('.row')).count().then(function (rowCount) {
element.all(by.css('.altrow')).count().then(function (altRowCount) {
expect(rowCount + altRowCount).toEqual(1);
})
});
&#13;
我收到陈旧元素的错误。我现在不确定如何获得行本身的计数。感谢
答案 0 :(得分:1)
您可以计算tr
或class="row"
的{{1}}元素:
class="altrow"