我正在研究一个使用Protractor(v 0.24.1),Cucumber(v 0.4.0),Chai(v 1.9.1)和Chai-as-promise(v 4.1.1)的测试框架。
Selinium-server-standalone.jar(v 2.41.0) chromedriver(v 2.10)
在此步骤中,我将以不同的方式验证计数。在承诺的第二种方式中,第二种方式使用chai-as-promised库来验证计数。
element.all(by.css('[ticket-id]')).then(function (tickets) {
expect(tickets.length).to.equal(2, "length correct");
//expect(tickets.length).to.equal(3, "length wrong");
});
expect(element.all(by.css('[ticket-id]')).count()).to.eventually.to.equal(2).and.notify(next);
这传递了,我收到了消息:
1 scenario (1 passed)
3 steps (3 passed)
Process finished with exit code 0
现在当我改变那里的期望然后失败时,一切都会死亡。
element.all(by.css('[ticket-id]')).then(function (tickets) {
//expect(tickets.length).to.equal(2, "length correct");
expect(tickets.length).to.equal(3, "length wrong");
});
现在我只收到消息:
Process finished with exit code 1
此故障会在没有堆栈跟踪或任何可帮助调试的情况下停止测试执行。 有谁知道为什么或解决这个问题?
我们正在考虑更新可能有用的Protractor。
答案 0 :(得分:1)
以下解决方案解决了您的问题:
element.all(by.css('[ticket-id]')).then(function (tickets) {
expect(tickets.length).to.equal(2, "length correct");
//expect(tickets.length).to.equal(3, "length wrong");
}).catch(function(err){
callback(err);
});
expect(element.all(by.css('[ticketid]')).count()).to.eventually.to.equal(2).and.notify(next);