【问题标题】:Potractor not failing test even if it does not meet expected condition即使不符合预期条件,Potractor 也未通过测试
【发布时间】:2017-10-03 23:09:38
【问题描述】:

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

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

这是最后一步的代码

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. 如何处理预期条件引发的异常

【问题讨论】:

  • 我不确定,但请尝试在期望之前删除 return。

标签: protractor mocha.js chai cucumberjs


【解决方案1】:

你可以尝试使用回调吗:

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);
    })
});

【讨论】:

    猜你喜欢
    • 2021-10-08
    • 1970-01-01
    • 1970-01-01
    • 2020-12-31
    • 2020-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多