AssertionError:期望false等于true

时间:2017-09-29 11:29:57

标签: angularjs protractor cucumber e2e-testing cucumberjs

以下是代码:

this.Then(/^I click to the next button on the edit page$/,function(callback) {
    targetPO.getEditNextButton().isPresent().then(function(){
        targetPO.getEditNextButton().click().then(callback);
    });
})

我得到了:

  

AssertionError:预期false等于true

错误。我找不到任何有用的教程,只有圣人故事。

错误的原因是什么?

这是getEditNextButton()函数:

function getEditNextButton() {
    return element(by.id(selectors.editNextButton));
}

1 个答案:

答案 0 :(得分:0)

看起来您调用该函数的方式存在问题。它可以通过两种方式解决:
1)从函数getEditNextButton()中删除 元素 中的'元素'(by.id (selectors.editNextButton));

要么

2)因为,通过调用 getEditNextButton()函数,您将返回'element(by.id(...)'。所以,您应该删除 元素。 来自'element.getEditNextButton()。click()。then(callback);'