0

我需要检查一个页面中列出的元素是否超过十二个。我做到了,但期望我有这个错误:

AssertionError: expected '24' to be a number or a date

现在,24 显然是一个数字,那么有什么问题呢?为什么这个断言错误?你能帮我解决这个问题吗?

这是我的 stepdefinition.js

Given('there are more than twelve elements listed', function (next) {
    let listed_count = element(by.css('span[class="total-results"]'));
    listed_count.getText().then(function(text){
            console.log('How much elements?: ', text);
            browser.sleep(1111);
            return expect(text).to.be.above(12);
      })
      next();
});

谢谢你。

4

1 回答 1

3

listed_count.getText() 返回文本。您需要将其转换为数字:

parseInt(text);
于 2018-06-13T14:06:16.833 回答