protractor, AssertionError: expected '24' to be a number or a date
protractor, AssertionError: expected '24' to be a number or a date
我需要检查页面中列出的元素是否超过十二个。
我做到了,但我期望我有这个错误:
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();
});
谢谢。
listed_count.getText() returns 文本。您需要将其转换为数字:
parseInt(text);
我需要检查页面中列出的元素是否超过十二个。 我做到了,但我期望我有这个错误:
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();
});
谢谢。
listed_count.getText() returns 文本。您需要将其转换为数字:
parseInt(text);