【发布时间】:2015-10-01 20:27:20
【问题描述】:
我需要将表中记录数的值存储在某个变量中,以便最近使用它。 现在尝试简单地打印这样的记录数:
var rows = element.all(by.xpath('//*[@id="content"]/div/div/table/tbody/tr'));
var sum = rows.count();
console.log(sum.getText());
或类似:
element.all(by.xpath('//*[@id="content"]/div/div/table/tbody/tr')).count().then(function(count) { console.log(count); });
但每次我收到Failed: object is not a function。
有人可以帮忙吗?
从这个帖子尝试过的解决方案: Protractor - count elements in repeater and print it - 但没用。
我想做类似于Java代码的场景:
@Test
public void test() throws Exception {
When:
clickOn(welcomePage.usersButton);
clickOn(usersPage.archivedTab);
int numberOfRecords = getDriver().findElements(By.xpath("//*[@id=\"content\"]/div/div/table/tbody/tr")).size();
if (numberOfRecords > 0) { do test, test steps ar here } else {break test}
【问题讨论】:
标签: javascript java testing xpath protractor