Sapui5:我怎样才能在OPA5上执行一个动作呢?

时间:2017-09-13 10:01:11

标签: sapui5

我有一个测试journy,点击一个按钮,并期望一个特定的答案, 它的工作原理如下:

When.onTheHomePage.iPressTheSearchButton();
Then.onTheHomePage.iSholdGetResponse(answer);

所以点击按钮后我想知道我是否得到了正确答案。

问题是我想要一个动作,如果它没有找到答案,它会点击另一个按钮

iSholdGetResponse: function (sAnswer) {
    var modelAnswer;
    return this.waitFor({
        viewName: "Home",
        matchers: function (oPage) {
            var sExpectedObj = oPage.getModel("msgData").getData()['msgData'];
            var sExpectedRes = sExpectedObj[sExpectedObj.length-1];
            modelAnswer = sExpectedRes.Text.toLowerCase();

            if(modelAnswer.indexOf(sAnswer.toLowerCase()) >= 0){
                return true;
            }else{
              //NEED TO DO HERE CLICK BUTTON *******
           }
        },
        success: function (data) {
            Opa5.assert.ok(true, "Answer Correct! (" +modelAnswer +")");
        },
        errorMessage: "Not expected answer"
    });
}

那么如何在匹配属性中触发点击?

1 个答案:

答案 0 :(得分:1)

你是在单独的测试中做到的:

1.Test 1

When.onTheHomePage.iPressTheSearchButton();
    Then.onTheHomePage.iSholdGetResponse(answer).and.iSeeTheIncorrectAnswer;

2.Test 2

When.onTheHomePage.iPressAnAnotherButton();
    Then.onTheHomePage.iSholdGetResponse(answer)...