1

I have a similar question as this

But, how can I check the content of sap.m.MessageToast is correct or not?

iShouldSeeAToastMessage : function(sText) {
    return this.waitFor({
        pollingInterval : 100,
        check : function() {
            return !!sap.ui.test.Opa5.getJQuery()(".sapMMessageToast").length;
        },
        success : function (oMessage) {
            strictEqual(oMessage[0].getText(), sText, "The message display correctly");
        },
        errorMessage : "No Toast message detected!"
    });
}

I tried the above code. But, maybe, the success callback returns no object. So, I got the error message: Cannot read property '0' of null

=======================================

I tried the following code. The testcase is passed. But, I am not sure it is a correct test code.

success : function () {
    strictEqual(sap.ui.test.Opa5.getJQuery()(".sapMMessageToast")[0].innerHTML, sText, "The message display correctly");
}
Community
  • 1
  • 1
Vu Le Anh
  • 708
  • 2
  • 8
  • 21

1 Answers1

1

I built a JS Bin illustrating a matcher.

Here is the matcher code:

new Opa5().waitFor({
            matchers: function () {
              return  jQuery(".sapMMessageToast").text();
            },
            success: function (sMessage) {
              MessageToast.show("found a message toast with the message " + sMessage);
            }
});

If you return something differen than a boolean in matchers it will get passed to success.

it is described in the API documentation in the 'matchers' parameter.

TobiasOetzel
  • 483
  • 2
  • 4