即使不符合预期条件,Potractor也不会失败测试

时间:2017-10-03 23:09:39

标签: protractor mocha chai cucumberjs

我是新的量角器框架,即使预期的条件没有得到满足,测试也没有失败

这是我执行测试时的输出:

TestOutput

这是最后一步的代码

this.Then(/^"View All Interactions" link button should stay at the top of list$/, () => {

    waitForPresence(mobileQADashboard.pageElements.viewAllInteractionsLink);
    waitForPresence(mobileQADashboard.getVisibleDataContainer());


    mobileQADashboard.getVisibleDataContainer().getLocation().then(function (ContainerLocation) {

        return expect(mobileQADashboard.pageElements.viewAllInteractionsLink.getLocation(),"View Interactions Link is not above").to.eventually.have.property('y').that.is.below(
            ContainerLocation.y
        );
    })
});
  1. 为什么即使不满足期望条件也会通过该步骤
  2. 如何处理期望条件引发的异常

1 个答案:

答案 0 :(得分:0)

您可以尝试使用回调:

this.Then(/^"View All Interactions" link button should stay at the top of list$/, (callback) => {

    waitForPresence(mobileQADashboard.pageElements.viewAllInteractionsLink);
    waitForPresence(mobileQADashboard.getVisibleDataContainer());

    mobileQADashboard.getVisibleDataContainer().getLocation().then(function (ContainerLocation) {
        expect(mobileQADashboard.pageElements.viewAllInteractionsLink.getLocation(),"View Interactions Link is not above").to.eventually.have.property('y').that.is.below(
            ContainerLocation.y
        ).and.notify(callback);
    })
});